All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.snowdrop.istio.api.model.v1.mixer.ReferencedAttributesFluentImpl Maven / Gradle / Ivy

package me.snowdrop.istio.api.model.v1.mixer;

import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import me.snowdrop.istio.api.builder.Nested;
import java.lang.String;
import me.snowdrop.istio.api.builder.Predicate;
import java.lang.Integer;
import java.lang.Deprecated;
import javax.validation.Valid;
import me.snowdrop.istio.api.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class ReferencedAttributesFluentImpl> extends me.snowdrop.istio.api.builder.BaseFluent implements ReferencedAttributesFluent{

    private List attributeMatches =  new ArrayList();
    private List words;

    public ReferencedAttributesFluentImpl(){
    }
    public ReferencedAttributesFluentImpl(ReferencedAttributes instance){
            this.withAttributeMatches(instance.getAttributeMatches()); 
            this.withWords(instance.getWords()); 
    }

    public A addToAttributeMatches(int index,AttributeMatch item){
            if (this.attributeMatches == null) {this.attributeMatches = new ArrayList();}
            AttributeMatchBuilder builder = new AttributeMatchBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.attributeMatches.add(index >= 0 ? index : attributeMatches.size(), builder); return (A)this;
    }

    public A setToAttributeMatches(int index,AttributeMatch item){
            if (this.attributeMatches == null) {this.attributeMatches = new ArrayList();}
            AttributeMatchBuilder builder = new AttributeMatchBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= attributeMatches.size()) { attributeMatches.add(builder); } else { attributeMatches.set(index, builder);}
             return (A)this;
    }

    public A addToAttributeMatches(AttributeMatch... items){
            if (this.attributeMatches == null) {this.attributeMatches = new ArrayList();}
            for (AttributeMatch item : items) {AttributeMatchBuilder builder = new AttributeMatchBuilder(item);_visitables.add(builder);this.attributeMatches.add(builder);} return (A)this;
    }

    public A addAllToAttributeMatches(Collection items){
            if (this.attributeMatches == null) {this.attributeMatches = new ArrayList();}
            for (AttributeMatch item : items) {AttributeMatchBuilder builder = new AttributeMatchBuilder(item);_visitables.add(builder);this.attributeMatches.add(builder);} return (A)this;
    }

    public A removeFromAttributeMatches(AttributeMatch... items){
            for (AttributeMatch item : items) {AttributeMatchBuilder builder = new AttributeMatchBuilder(item);_visitables.remove(builder);if (this.attributeMatches != null) {this.attributeMatches.remove(builder);}} return (A)this;
    }

    public A removeAllFromAttributeMatches(Collection items){
            for (AttributeMatch item : items) {AttributeMatchBuilder builder = new AttributeMatchBuilder(item);_visitables.remove(builder);if (this.attributeMatches != null) {this.attributeMatches.remove(builder);}} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildAttributeMatches instead.
 */
@Deprecated public List getAttributeMatches(){
            return build(attributeMatches);
    }

    public List buildAttributeMatches(){
            return build(attributeMatches);
    }

    public AttributeMatch buildAttributeMatch(int index){
            return this.attributeMatches.get(index).build();
    }

    public AttributeMatch buildFirstAttributeMatch(){
            return this.attributeMatches.get(0).build();
    }

    public AttributeMatch buildLastAttributeMatch(){
            return this.attributeMatches.get(attributeMatches.size() - 1).build();
    }

    public AttributeMatch buildMatchingAttributeMatch(me.snowdrop.istio.api.builder.Predicate predicate){
            for (AttributeMatchBuilder item: attributeMatches) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withAttributeMatches(List attributeMatches){
            if (this.attributeMatches == null) { this.attributeMatches = new ArrayList();} else {_visitables.removeAll(this.attributeMatches); this.attributeMatches.clear();}
            if (attributeMatches != null) {for (AttributeMatch item : attributeMatches){this.addToAttributeMatches(item);}} return (A) this;
    }

    public A withAttributeMatches(AttributeMatch... attributeMatches){
            this.attributeMatches.clear(); if (attributeMatches != null) {for (AttributeMatch item :attributeMatches){ this.addToAttributeMatches(item);}} return (A) this;
    }

    public Boolean hasAttributeMatches(){
            return attributeMatches != null && !attributeMatches.isEmpty();
    }

    public A addNewAttributeMatch(Integer condition,Integer mapKey,Integer name,String regex){
            return (A)addToAttributeMatches(new AttributeMatch(condition, mapKey, name, regex));
    }

    public ReferencedAttributesFluent.AttributeMatchesNested addNewAttributeMatch(){
            return new AttributeMatchesNestedImpl();
    }

    public ReferencedAttributesFluent.AttributeMatchesNested addNewAttributeMatchLike(AttributeMatch item){
            return new AttributeMatchesNestedImpl(-1, item);
    }

    public ReferencedAttributesFluent.AttributeMatchesNested setNewAttributeMatchLike(int index,AttributeMatch item){
            return new AttributeMatchesNestedImpl(index, item);
    }

    public ReferencedAttributesFluent.AttributeMatchesNested editAttributeMatch(int index){
            if (attributeMatches.size() <= index) throw new RuntimeException("Can't edit attributeMatches. Index exceeds size.");
            return setNewAttributeMatchLike(index, buildAttributeMatch(index));
    }

    public ReferencedAttributesFluent.AttributeMatchesNested editFirstAttributeMatch(){
            if (attributeMatches.size() == 0) throw new RuntimeException("Can't edit first attributeMatches. The list is empty.");
            return setNewAttributeMatchLike(0, buildAttributeMatch(0));
    }

    public ReferencedAttributesFluent.AttributeMatchesNested editLastAttributeMatch(){
            int index = attributeMatches.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last attributeMatches. The list is empty.");
            return setNewAttributeMatchLike(index, buildAttributeMatch(index));
    }

    public ReferencedAttributesFluent.AttributeMatchesNested editMatchingAttributeMatch(me.snowdrop.istio.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i();}
            this.words.add(index, item);
            return (A)this;
    }

    public A setToWords(int index,String item){
            this.words.set(index, item); return (A)this;
    }

    public A addToWords(String... items){
            for (String item : items) {this.words.add(item);} return (A)this;
    }

    public A addAllToWords(Collection items){
            for (String item : items) {this.words.add(item);} return (A)this;
    }

    public A removeFromWords(String... items){
            for (String item : items) {if (this.words!= null){ this.words.remove(item);}} return (A)this;
    }

    public A removeAllFromWords(Collection items){
            for (String item : items) {if (this.words!= null){ this.words.remove(item);}} return (A)this;
    }

    public List getWords(){
            return this.words;
    }

    public String getWord(int index){
            return this.words.get(index);
    }

    public String getFirstWord(){
            return this.words.get(0);
    }

    public String getLastWord(){
            return this.words.get(words.size() - 1);
    }

    public String getMatchingWord(me.snowdrop.istio.api.builder.Predicate predicate){
            for (String item: words) { if(predicate.apply(item)){return item;} } return null;
    }

    public A withWords(List words){
            if (this.words == null) { this.words = new ArrayList();} else {_visitables.removeAll(this.words); this.words.clear();}
            if (words != null) {for (String item : words){this.addToWords(item);}} return (A) this;
    }

    public A withWords(String... words){
            this.words.clear(); if (words != null) {for (String item :words){ this.addToWords(item);}} return (A) this;
    }

    public Boolean hasWords(){
            return words != null && !words.isEmpty();
    }

    public boolean equals(Object o){
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            if (!super.equals(o)) return false;
            ReferencedAttributesFluentImpl that = (ReferencedAttributesFluentImpl) o;
            if (attributeMatches != null ? !attributeMatches.equals(that.attributeMatches) :that.attributeMatches != null) return false;
            if (words != null ? !words.equals(that.words) :that.words != null) return false;
            return true;
    }


    public class AttributeMatchesNestedImpl extends AttributeMatchFluentImpl> implements ReferencedAttributesFluent.AttributeMatchesNested,me.snowdrop.istio.api.builder.Nested{

            private final AttributeMatchBuilder builder;
        private final int index;
    
            AttributeMatchesNestedImpl(int index,AttributeMatch item){
                    this.index = index;
                    this.builder = new AttributeMatchBuilder(this, item);
            }
            AttributeMatchesNestedImpl(){
                    this.index = -1;
                    this.builder = new AttributeMatchBuilder(this);
            }
    
    public N and(){
            return (N) ReferencedAttributesFluentImpl.this.setToAttributeMatches(index, builder.build());
    }
    public N endAttributeMatch(){
            return and();
    }

}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy