com.ibm.cloud.objectstorage.services.s3.model.BucketTaggingConfiguration Maven / Gradle / Ivy
Show all versions of ibm-cos-java-sdk-bundle Show documentation
/*
* Copyright 2010-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Portions copyright 2006-2009 James Murty. Please see LICENSE.txt
* for applicable license terms and NOTICE.txt for applicable notices.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.ibm.cloud.objectstorage.services.s3.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.ibm.cloud.objectstorage.services.s3.AmazonS3;
public class BucketTaggingConfiguration implements Serializable {
private List tagSets = null;
/**
*
* Creates a new bucket tagging configuration.
* By default, the newly created configuration is empty.
*
*
* Passing the new configuration directly to
* {@link AmazonS3#setBucketTaggingConfiguration(String,BucketTaggingConfiguration)}
* will remove any existing bucket tagging configuration.
*
*
* @see BucketTaggingConfiguration#BucketTaggingConfiguration(Collection)
*/
public BucketTaggingConfiguration() {
this.tagSets = new ArrayList( 1 );
}
/**
*
* Creates a new bucket Tagging configuration containing the specified
* TopicConfigurations
.
*
*
* Passing the new configuration directly to
* {@link AmazonS3#setBucketTaggingConfiguration(String,BucketTaggingConfiguration)}
* will set the bucket's Tagging configuration and overwrite any existing configuration.
*
*
* @see BucketTaggingConfiguration#BucketTaggingConfiguration()
*/
public BucketTaggingConfiguration( Collection tagSets ) {
this.tagSets = new ArrayList( 1 );
this.tagSets.addAll( tagSets );
}
/**
*
* Sets the {@link TagSet}
* TagSets
and returns this object,
* enabling additional method calls to be chained together.
*
*
* Calling this method will overwrite any
* previously set TagSets
for this object.
*
*
* @param tagSets
* A set of TagSet objects.
*
* @return The updated {@link BucketTaggingConfiguration} object,
* enabling additional method calls to be chained together.
*
* @see BucketTaggingConfiguration#setTagSets(Collection)
*/
public BucketTaggingConfiguration withTagSets( TagSet... tagSets ) {
this.tagSets.clear();
for ( int index = 0; index < tagSets.length; index++ ) {
this.tagSets.add( tagSets[ index ] );
}
return this;
}
/**
*
* Sets the {@link TagSet}.
*
*
* Calling this method will overwrite any
* previously set TagSets
for this object.
*
*
* @param tagSets
* A collection of TagSet objects.
*
* @see BucketTaggingConfiguration#withTagSets(TagSet...)
*/
public void setTagSets( Collection tagSets ) {
this.tagSets.clear();
this.tagSets.addAll( tagSets );
}
/**
*
* Gets the list of {@link TagSet} objects
* contained in this object. This method may return an empty list if no TagSet
* objects are present.
*
*
* @return The list of TagSet
objects contained in this object.
* May return an empty list.
*/
public List getAllTagSets() {
return this.tagSets;
}
/**
*
* Gets the first {@link TagSet} object contained in this object. This method may return null
* list if no TagSet
objects are present.
*
* @return The first TagSet
object contained in the object
*/
public TagSet getTagSet() {
return this.tagSets.get( 0 );
}
/**
*
* Gets the {@link TagSet} object at the specified index contained in this object.
*
*
* @param index
* The index of the TagSet
object to return
*
* @return The TagSet
object contained in the object
*/
public TagSet getTagSetAtIndex( int index ) {
return this.tagSets.get( index );
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("{");
sb.append("TagSets: " + this.getAllTagSets() );
sb.append("}");
return sb.toString();
}
}