Class Schema

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Schema.Builder<S extends Schema>
      Abstract builder class for the builder classes of Schema subclasses.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String schemaLocation
      Deprecated.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Schema​(Schema.Builder<?> builder)
      Constructor.
    • Method Summary

      Modifier and Type Method Description
      protected boolean canEqual​(java.lang.Object other)
      Since we add state in subclasses, but want those subclasses to be non final, this allows us to have equals methods that satisfy the equals contract.
      boolean definesProperty​(java.lang.String field)
      Determines if this Schema instance defines any restrictions for the object property denoted by field.
      void describeTo​(JSONPrinter writer)
      Describes the instance as a JSONObject to writer.
      boolean equals​(java.lang.Object o)  
      protected ValidationException failure​(java.lang.Class<?> expectedType, java.lang.Object actualValue)
      Deprecated.
      protected ValidationException failure​(java.lang.String message, java.lang.String keyword)
      Deprecated.
      java.lang.Object getDefaultValue()  
      java.lang.String getDescription()  
      java.lang.String getId()  
      SchemaLocation getLocation()  
      java.lang.String getSchemaLocation()  
      java.lang.String getTitle()  
      java.util.Map<java.lang.String,​java.lang.Object> getUnprocessedProperties()
      Returns the properties of the original schema JSON which aren't keywords of json schema (therefore they weren't recognized during schema loading).
      boolean hasDefaultValue()  
      int hashCode()  
      java.lang.Boolean isNullable()  
      java.lang.Boolean isReadOnly()  
      java.lang.Boolean isWriteOnly()  
      java.lang.String toString()  
      void validate​(java.lang.Object subject)
      Performs the schema validation.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • schemaLocation

        @Deprecated
        protected final java.lang.String schemaLocation
        Deprecated.
    • Constructor Detail

      • Schema

        protected Schema​(Schema.Builder<?> builder)
        Constructor.
        Parameters:
        builder - the builder containing the optional title, description and id attributes of the schema
    • Method Detail

      • validate

        public void validate​(java.lang.Object subject)
        Performs the schema validation.
        Parameters:
        subject - the object to be validated
        Throws:
        ValidationException - if the subject is invalid against this schema.
      • definesProperty

        public boolean definesProperty​(java.lang.String field)
        Determines if this Schema instance defines any restrictions for the object property denoted by field. The field should be a JSON pointer, denoting the property to be queried.

        For example the field "#/rectangle/a" is defined by the following schema:

         
         objectWithSchemaRectangleDep" : {
           "type" : "object",
           "dependencies" : {
               "d" : {
                   "type" : "object",
                   "properties" : {
                       "rectangle" : {"$ref" : "#/definitions/Rectangle" }
                   }
               }
           },
           "definitions" : {
               "size" : {
                   "type" : "number",
                   "minimum" : 0
               },
               "Rectangle" : {
                   "type" : "object",
                   "properties" : {
                       "a" : {"$ref" : "#/definitions/size"},
                       "b" : {"$ref" : "#/definitions/size"}
                   }
               }
            }
         }
         
         
        The default implementation of this method always returns false.
        Parameters:
        field - should be a JSON pointer in its string representation.
        Returns:
        true if the propertty denoted by field is defined by this schema instance
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getTitle

        public java.lang.String getTitle()
      • getDescription

        public java.lang.String getDescription()
      • getId

        public java.lang.String getId()
      • getSchemaLocation

        public java.lang.String getSchemaLocation()
      • getDefaultValue

        public java.lang.Object getDefaultValue()
      • hasDefaultValue

        public boolean hasDefaultValue()
      • isNullable

        public java.lang.Boolean isNullable()
      • isReadOnly

        public java.lang.Boolean isReadOnly()
      • isWriteOnly

        public java.lang.Boolean isWriteOnly()
      • getUnprocessedProperties

        public java.util.Map<java.lang.String,​java.lang.Object> getUnprocessedProperties()
        Returns the properties of the original schema JSON which aren't keywords of json schema (therefore they weren't recognized during schema loading).
      • describeTo

        public void describeTo​(JSONPrinter writer)
        Describes the instance as a JSONObject to writer.

        First it adds the "title , "description" and "id" properties then calls describePropertiesTo(JSONPrinter), which will add the subclass-specific properties.

        It is used by toString() to serialize the schema instance into its JSON representation.

        Parameters:
        writer - it will receive the schema description
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • failure

        @Deprecated
        protected ValidationException failure​(java.lang.String message,
                                              java.lang.String keyword)
        Deprecated.
      • failure

        @Deprecated
        protected ValidationException failure​(java.lang.Class<?> expectedType,
                                              java.lang.Object actualValue)
        Deprecated.
      • canEqual

        protected boolean canEqual​(java.lang.Object other)
        Since we add state in subclasses, but want those subclasses to be non final, this allows us to have equals methods that satisfy the equals contract.

        http://www.artima.com/lejava/articles/equality.html

        Parameters:
        other - the subject of comparison
        Returns:
        true if this can be equal to other