org.schemarepo
Class ReadOnlyRepository

java.lang.Object
  extended by org.schemarepo.BaseRepository
      extended by org.schemarepo.DelegatingRepository
          extended by org.schemarepo.ReadOnlyRepository
All Implemented Interfaces:
Closeable, Repository

public class ReadOnlyRepository
extends DelegatingRepository

ReadOnlyRepository is a Repository implementation that wraps another Repository and rejects all operations that can modify the state of the Repository.

register(String, SubjectConfig), Subject.register(String) and Subject.registerIfLatest(String, SchemaEntry) throw IllegalStateException if called.


Field Summary
 
Fields inherited from class org.schemarepo.DelegatingRepository
repo
 
Fields inherited from class org.schemarepo.BaseRepository
closed, logger
 
Constructor Summary
ReadOnlyRepository(Repository repo)
          Create a repository that disallows mutations to the underlying repository.
 
Method Summary
 Subject lookup(String subjectName)
          Returns the subject if it exists, null otherwise.
 Subject register(String subjectName, SubjectConfig config)
          Attempt to create a Subject with the given name and validator.
 Iterable<Subject> subjects()
          List all subjects.
 
Methods inherited from class org.schemarepo.DelegatingRepository
close, exposeConfiguration, isValid
 
Methods inherited from class org.schemarepo.BaseRepository
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadOnlyRepository

@Inject
public ReadOnlyRepository(Repository repo)
Create a repository that disallows mutations to the underlying repository.

Parameters:
repo - The repository to wrap
Method Detail

register

public Subject register(String subjectName,
                        SubjectConfig config)
Description copied from interface: Repository
Attempt to create a Subject with the given name and validator.

Specified by:
register in interface Repository
Overrides:
register in class DelegatingRepository
Parameters:
subjectName - The name of the subject. Must not be null.
config - The subject configuration. May be null.
Returns:
The newly created Subject, or an equivalent one if already created. Does not return null.

lookup

public Subject lookup(String subjectName)
Description copied from interface: Repository
Returns the subject if it exists, null otherwise.

Specified by:
lookup in interface Repository
Overrides:
lookup in class DelegatingRepository
Parameters:
subjectName - the subject name
Returns:
The subject if it exists, null otherwise.

subjects

public Iterable<Subject> subjects()
Description copied from interface: Repository
List all subjects. Does not return null.

Specified by:
subjects in interface Repository
Overrides:
subjects in class DelegatingRepository


Copyright © 2015. All rights reserved.