public void assign(StructDataType type) { super.assign(type); superType = type.superType; }
protected void assign(BaseStructDataType type) { BaseStructDataType stype = type.clone(); fieldIds = stype.fieldIds; fieldIdsV6 = stype.fieldIdsV6; fields = stype.fields; }
public Collection<Field> getFieldsThisTypeOnly() { return Collections.unmodifiableCollection(super.getFields()); }
@Override public Field getField(Integer fieldId, int version) { Field f = super.getField(fieldId, version); if (f == null && superType != null) { f = superType.getField(fieldId, version); } return f; }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (superType != null ? superType.hashCode() : 0); return result; } }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof StructDataType)) return false; if (!super.equals(o)) return false; StructDataType that = (StructDataType) o; if (superType != null ? !superType.equals(that.superType) : that.superType != null) return false; return true; }
public void addField(Field field) { if (fields.containsKey(field.getName())) { throw new IllegalArgumentException("Struct " + getName() + " already contains field with name " + field.getName()); } if (fieldIds.containsKey(field.getId(Document.SERIALIZED_VERSION))) { throw new IllegalArgumentException("Struct " + getName() + " already contains field with id " + field.getId(Document.SERIALIZED_VERSION)); } if (fieldIdsV6.containsKey(field.getId(6))) { throw new IllegalArgumentException("Struct " + getName() + " already contains a field with deprecated document serialization id " + field.getId(6)); } fields.put(field.getName(), field); fieldIds.put(field.getId(Document.SERIALIZED_VERSION), field); fieldIdsV6.put(field.getId(6), field); }
@Override public void addField(Field field) { if (hasField(field)) { throw new IllegalArgumentException("Struct already has field " + field); } if ((superType != null) && superType.hasField(field)) { throw new IllegalArgumentException(field.toString() + " already present in inherited type '" + superType.toString() + "', " + this.toString() + " cannot override."); } super.addField(field); }
@Override public Field getField(String fieldName) { Field f = super.getField(fieldName); if (f == null && superType != null) { f = superType.getField(fieldName); } return f; }
@Override public boolean hasField(Field field, int version) { boolean f = super.hasField(field, version); if (!f && superType != null) { f = superType.hasField(field, version); } return f; }
@Override public Field getField(int id) { Field f = super.getField(id); if (f == null && superType != null) { f = superType.getField(id); } return f; }
@Override public Collection<Field> getFields() { if (superType == null) { return Collections.unmodifiableCollection(super.getFields()); } Collection<Field> fieldsBuilder = new ArrayList<>(); fieldsBuilder.addAll(super.getFields()); fieldsBuilder.addAll(superType.getFields()); return ImmutableList.copyOf(fieldsBuilder); }
@Override public StructDataType clone() { StructDataType type = (StructDataType) super.clone(); type.superType = this.superType; return type; }
public boolean hasField(Field field, int version) { Field f = getField(field.getId(version), version); return f != null && f.equals(field); }