public static Schema addAttributeToSchema(Schema schema,Attribute attribute){
  if (schema.containsField(attribute.getFieldName())) {
    return schema;
  }
  List<Attribute> attributes=new ArrayList<>(schema.getAttributes());
  attributes.add(attribute);
  Schema newSchema=new Schema(attributes.toArray(new Attribute[attributes.size()]));
  return newSchema;
}

public static Schema addAttributeToSchema ( Schema schema , Attribute attribute ) { if ( schema . containsField ( attribute . getFieldName ( ) ) ) { return schema ; } List < Attribute > attributes = new ArrayList < > ( schema . getAttributes ( ) ) ; attributes . add ( attribute ) ; Schema newSchema = new Schema ( attributes . toArray ( new Attribute [ attributes . size ( ) ] ) ) ; return newSchema ; }
add an attribute to an existing schema ( if the attribute doesn ' t exist ) .
