org.schemarepo
Class DelegatingSubject

java.lang.Object
  extended by org.schemarepo.Subject
      extended by org.schemarepo.DelegatingSubject

public abstract class DelegatingSubject
extends Subject

A DelegatingSubject is a Subject that delegates work to an underlying Subject. Specific implementations may override various methods.


Constructor Summary
protected DelegatingSubject(Subject delegate)
          A DelegatingSubject delegates work to a provided Subject.
 
Method Summary
 Iterable<SchemaEntry> allEntries()
          List the ids of schemas registered with the given subject, ordered from most recent to oldest.
 SubjectConfig getConfig()
           
 boolean integralKeys()
          Indicates whether the keys generated by this subject can be expected to parse as an integer.
 SchemaEntry latest()
          Lookup the most recently registered schema for the given subject.
 SchemaEntry lookupById(String id)
          Lookup the SchemaEntry for the given subject by id.
 SchemaEntry lookupBySchema(String schema)
          Lookup the SchemaEntry for the given schema.
 SchemaEntry register(String schema)
          If the provided schema has already been registered in this subject, return the id.
 SchemaEntry registerIfLatest(String schema, SchemaEntry latest)
          Register the provided schema only if the current latest schema matches the provided latest entry.
 
Methods inherited from class org.schemarepo.Subject
cacheWith, getName, readOnly, toString, validatingSubject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DelegatingSubject

protected DelegatingSubject(Subject delegate)
A DelegatingSubject delegates work to a provided Subject.

Method Detail

register

public SchemaEntry register(String schema)
                     throws SchemaValidationException
Description copied from class: Subject
If the provided schema has already been registered in this subject, return the id. If the provided schema has not been registered in this subject, register it and return its id. Idempotent -- If two users simultaneously register the same schema, they will both get the same SchemaEntry result and succeed.

Specified by:
register in class Subject
Parameters:
schema - The schema to register
Returns:
The id of the schema
Throws:
SchemaValidationException - If the schema change is not valid according the validation rules of the subject

registerIfLatest

public SchemaEntry registerIfLatest(String schema,
                                    SchemaEntry latest)
                             throws SchemaValidationException
Description copied from class: Subject
Register the provided schema only if the current latest schema matches the provided latest entry.

Specified by:
registerIfLatest in class Subject
Parameters:
schema - The schema to register
latest - the entry that must match the current actual latest value in order to register this schema.
Returns:
The id of the schema, or null if latest does not match.
Throws:
SchemaValidationException - If the schema change is not valid according the validation rules of the subject

lookupBySchema

public SchemaEntry lookupBySchema(String schema)
Description copied from class: Subject
Lookup the SchemaEntry for the given schema. Since the mapping of schema to id is immutable, this result can be cached.

Specified by:
lookupBySchema in class Subject
Parameters:
schema - The schema to look up
Returns:
The SchemaEntry of the schema or null if the schema is not registered

lookupById

public SchemaEntry lookupById(String id)
Description copied from class: Subject
Lookup the SchemaEntry for the given subject by id. Since the mapping of schema to id is immutable the result can be cached.

Specified by:
lookupById in class Subject
Parameters:
id - the id of the schema to look up
Returns:
The SchemaEntry of the schema or null if no such schema is registered for the provided id

latest

public SchemaEntry latest()
Description copied from class: Subject
Lookup the most recently registered schema for the given subject. This result is not cacheable, since the latest schema may change.

Specified by:
latest in class Subject
Returns:
The SchemaEntry or null if no schema is registered with this subject

allEntries

public Iterable<SchemaEntry> allEntries()
Description copied from class: Subject
List the ids of schemas registered with the given subject, ordered from most recent to oldest. This result is not cacheable, since the SchemaEntry in the subject may grow over time.

Specified by:
allEntries in class Subject
Returns:
the SchemaEntry objects in this subject, ordered from most recent to oldest.

getConfig

public SubjectConfig getConfig()
Specified by:
getConfig in class Subject
Returns:
The SubjectConfig for this Subject

integralKeys

public boolean integralKeys()
Description copied from class: Subject
Indicates whether the keys generated by this subject can be expected to parse as an integer. This delegates all the way through to the backing store and is not configurable through the Repository/Subject API, since implementations of the backing store are what determines how keys are generated; the contract otherwise is merely that they are Strings and unique per subject.

Specified by:
integralKeys in class Subject
Returns:
a boolean indicating if the IDs for this Subject are integers


Copyright © 2015. All rights reserved.