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

org.jsonddl.model.Property Maven / Gradle / Ivy

package org.jsonddl.model;
/**
   * A property is a pair of a name and a type.
   */
@javax.annotation.Generated(value="org.jsonddl.generator.industrial.IndustrialDialect", date="2012-04-04T08:47:13")
public interface Property
    extends org.jsonddl.JsonDdlObject
 {
  /**
   * Constructs instances of {@link Property}. Instances of Builder should not be
   * reused after calling {@link #build()}.
   */
  @javax.annotation.Generated(value="org.jsonddl.generator.industrial.IndustrialDialect", date="2012-04-04T08:47:13")
  public static class Builder
      implements org.jsonddl.JsonDdlObject.Builder,  org.jsonddl.impl.Traversable, org.jsonddl.impl.Digested, Property {
    private PropertyImpl obj;
    public Builder() {
      this(new PropertyImpl());
    }
    Builder(PropertyImpl instance) {
      this.obj = instance;
    }
    public Property.Builder accept(org.jsonddl.JsonDdlVisitor visitor) {
      obj = new org.jsonddl.impl.ContextImpl.ObjectContext.Builder()
          .withValue(this)
          .withKind(org.jsonddl.model.Kind.DDL)
          .withMutability(true)
          .build().traverse(visitor).builder().obj;
      return this;
    }
    public Property build() {
      PropertyImpl toReturn = obj;
      obj = null;
      toReturn.Type = org.jsonddl.impl.Protected.object(toReturn.Type);
      return toReturn;
    }
    public Property.Builder builder() {
      return this;
    }
    public Property.Builder from(Property copyFrom) {
      withComment(copyFrom.getComment());
      withName(copyFrom.getName());
      withType(copyFrom.getType());
      return this;
    }
    public Property.Builder from(java.util.Map map) {
      accept(org.jsonddl.impl.JsonMapVisitor.fromJsonMap(map));
      return this;
    }
    public Class getDdlObjectType() {
      return Property.class;
    }
    public Property.Builder newInstance() {
      return new Property.Builder();
    }
    public java.util.Map toJsonObject() {
      return obj.toJsonObject();
    }
    public Property.Builder traverse(org.jsonddl.JsonDdlVisitor visitor) {
      withComment(
      new org.jsonddl.impl.ContextImpl.ValueContext.Builder()
        .withKind(org.jsonddl.model.Kind.STRING)
        .withLeafType(java.lang.String.class)
        .withMutability(true)
        .withProperty("comment")
        .withValue(obj.Comment)
        .build().traverse(visitor));
      withName(
      new org.jsonddl.impl.ContextImpl.ValueContext.Builder()
        .withKind(org.jsonddl.model.Kind.STRING)
        .withLeafType(java.lang.String.class)
        .withMutability(true)
        .withProperty("name")
        .withValue(obj.Name)
        .build().traverse(visitor));
      withType(
      new org.jsonddl.impl.ContextImpl.ObjectContext.Builder()
        .withKind(org.jsonddl.model.Kind.DDL)
        .withLeafType(Type.class)
        .withMutability(true)
        .withProperty("type")
        .withValue(obj.Type)
        .build().traverse(visitor));
      return this;
    }
    public byte[] computeDigest() {
      byte[] digest;
      org.jsonddl.impl.DigestVisitor v = new org.jsonddl.impl.DigestVisitor();
      accept(v);
      digest = v.getDigest();
      return digest;
    }

    public int hashCode() {
      byte[] digest = computeDigest();
      return (int)((digest[0] << 3) | (digest[1] << 2) | (digest[18] << 1) | digest[19]);
    }

    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof org.jsonddl.impl.Digested)) {
        return false;
      }
      byte[] d1 = computeDigest();
      byte[] d2 = ((org.jsonddl.impl.Digested) o).computeDigest();
      for (int i = 0, j = d1.length; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy