|
| 1 | +/* |
| 2 | + * Copyright 2010-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | + * You may not use this file except in compliance with the License. |
| 6 | + * A copy of the License is located at |
| 7 | + * |
| 8 | + * http://aws.amazon.com/apache2.0 |
| 9 | + * |
| 10 | + * or in the "license" file accompanying this file. This file is distributed |
| 11 | + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | + * express or implied. See the License for the specific language governing |
| 13 | + * permissions and limitations under the License. |
| 14 | + */ |
| 15 | +package com.ibm.cloud.objectstorage.services.s3.model.transform; |
| 16 | + |
| 17 | +import static com.ibm.cloud.objectstorage.services.s3.model.transform.BucketConfigurationXmlFactoryFunctions.writeObjectSizeGreaterThan; |
| 18 | +import static com.ibm.cloud.objectstorage.services.s3.model.transform.BucketConfigurationXmlFactoryFunctions.writeObjectSizeLessThan; |
| 19 | +import static com.ibm.cloud.objectstorage.services.s3.model.transform.BucketConfigurationXmlFactoryFunctions.writePrefix; |
| 20 | +import static com.ibm.cloud.objectstorage.services.s3.model.transform.BucketConfigurationXmlFactoryFunctions.writeTag; |
| 21 | + |
| 22 | +import com.ibm.cloud.objectstorage.services.s3.internal.XmlWriter; |
| 23 | +import com.ibm.cloud.objectstorage.services.s3.model.lifecycle.LifecycleAndOperator; |
| 24 | +import com.ibm.cloud.objectstorage.services.s3.model.lifecycle.LifecycleFilterPredicate; |
| 25 | +import com.ibm.cloud.objectstorage.services.s3.model.lifecycle.LifecycleObjectSizeGreaterThanPredicate; |
| 26 | +import com.ibm.cloud.objectstorage.services.s3.model.lifecycle.LifecycleObjectSizeLessThanPredicate; |
| 27 | +import com.ibm.cloud.objectstorage.services.s3.model.lifecycle.LifecyclePredicateVisitor; |
| 28 | +import com.ibm.cloud.objectstorage.services.s3.model.lifecycle.LifecyclePrefixPredicate; |
| 29 | +import com.ibm.cloud.objectstorage.services.s3.model.lifecycle.LifecycleTagPredicate; |
| 30 | + |
| 31 | +class LifecyclePredicateVisitorImpl implements LifecyclePredicateVisitor { |
| 32 | + private final XmlWriter xml; |
| 33 | + |
| 34 | + public LifecyclePredicateVisitorImpl(XmlWriter xml) { |
| 35 | + this.xml = xml; |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public void visit(LifecyclePrefixPredicate lifecyclePrefixPredicate) { |
| 40 | + writePrefix(xml, lifecyclePrefixPredicate.getPrefix()); |
| 41 | + } |
| 42 | + |
| 43 | + @Override |
| 44 | + public void visit(LifecycleTagPredicate lifecycleTagPredicate) { |
| 45 | + writeTag(xml, lifecycleTagPredicate.getTag()); |
| 46 | + } |
| 47 | + |
| 48 | + @Override |
| 49 | + public void visit(LifecycleObjectSizeGreaterThanPredicate lifecycleObjectSizeGreaterThanPredicate) { |
| 50 | + writeObjectSizeGreaterThan(xml, lifecycleObjectSizeGreaterThanPredicate.getObjectSizeGreaterThan()); |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public void visit(LifecycleObjectSizeLessThanPredicate lifecycleObjectSizeLessThanPredicate) { |
| 55 | + writeObjectSizeLessThan(xml, lifecycleObjectSizeLessThanPredicate.getObjectSizeLessThan()); |
| 56 | + } |
| 57 | + |
| 58 | + @Override |
| 59 | + public void visit(LifecycleAndOperator lifecycleAndOperator) { |
| 60 | + xml.start("And"); |
| 61 | + for (LifecycleFilterPredicate predicate : lifecycleAndOperator.getOperands()) { |
| 62 | + predicate.accept(this); |
| 63 | + } |
| 64 | + xml.end(); // </And> |
| 65 | + } |
| 66 | +} |
0 commit comments