public Builder add(SubDocAttribute attribute) { if (built) { throw new IllegalStateException("This buider has already been used to build a previous type"); } if (attributes.containsKey(attribute.getKey())) { throw new IllegalArgumentException("There is another attribute with key " + attribute.getKey()); } attributes.put(attribute.getKey(), attribute); return this; }
@Override public Builder add(SubDocAttribute att, ScalarValue value) { super.add(att, value); attributes.put(att.getKey(), att); return this; }
public Builder add(@Nonnull SubDocAttribute att, @Nonnull ScalarValue value) { if (values.containsKey(att.getKey())) { throw new IllegalArgumentException("There is another attribute with " + att.getKey()); } if (!att.getType().equals(value.getType())) { throw new IllegalArgumentException("Type of attribute " + att + " is " + att.getType() + " which is different " + "than the type of the given value (value is " + value + " and its type is " + value.getType()); } values.put(att.getKey(), value); return this; }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (getClass() != obj.getClass()) { return false; } final SubDocType other = (SubDocType) obj; if (other.hash != this.hash) { return false; } if (other.attributes.size() != this.attributes.size()) { return false; } for (SubDocAttribute thisAtt : this.attributes.values()) { SubDocAttribute otherAtt = other.getAttribute(thisAtt.getKey()); if (!otherAtt.equalsWithSameKey(thisAtt)) { return false; } } return true; }
@Override public Builder add(SubDocAttribute att, ScalarValue value) { String key = att.getKey(); Preconditions.checkArgument(att.equals(expectedType.getAttribute(key))); return super.add(att, value); }
private SubDocTable( String alias, Schema schema, Table<SubDocTableRecord> aliased, Field<?>[] parameters, @Nonnull SubDocType type, DatabaseInterface databaseInterface ) { super(alias, schema, aliased, parameters, ""); this.erasuredType = type; for (SubDocAttribute attibute : type.getAttributes()) { String fieldName = new SubDocHelper(databaseInterface).toColumnName(attibute.getKey()); DataType<?> dataType = databaseInterface.getValueToJooqDataTypeProvider().getDataType(attibute.getType()); createField( fieldName, dataType, this, ""); } this.databaseInterface = databaseInterface; }