code
stringlengths 25
201k
| docstring
stringlengths 19
96.2k
| func_name
stringlengths 0
235
| language
stringclasses 1
value | repo
stringlengths 8
51
| path
stringlengths 11
314
| url
stringlengths 62
377
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
@NonNull
public Builder<T> setQuery(@NonNull Query query, @NonNull Class<T> modelClass) {
return setQuery(query, new ClassSnapshotParser<>(modelClass));
}
|
Set the query to listen on and a {@link Class} to which data snapshots should be
converted. Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
|
setQuery
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setIndexedQuery(@NonNull Query keyQuery,
@NonNull DatabaseReference dataRef,
@NonNull SnapshotParser<T> parser) {
assertNull(mSnapshots, ERR_SNAPSHOTS_SET);
mSnapshots = new FirebaseIndexArray<>(keyQuery, dataRef, parser);
return this;
}
|
Set an indexed query to listen on and a {@link SnapshotParser} to parse data snapshots.
The keyQuery is used to find a list of IDs, which are then queried at the dataRef.
<p>
Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
|
setIndexedQuery
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setIndexedQuery(@NonNull Query keyQuery,
@NonNull DatabaseReference dataRef,
@NonNull Class<T> modelClass) {
return setIndexedQuery(keyQuery, dataRef, new ClassSnapshotParser<>(modelClass));
}
|
Set an indexed query to listen on and a {@link Class} to which data snapshots should be
converted. The keyQuery is used to find a list of keys, which are then queried at the
dataRef.
<p>
Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
|
setIndexedQuery
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setLayout(@LayoutRes int layout) {
mLayout = layout;
return this;
}
|
Set the resource ID for the item layout.
|
setLayout
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setLifecycleOwner(@Nullable LifecycleOwner owner) {
mOwner = owner;
return this;
}
|
Set the optional {@link LifecycleOwner}. Listening will stop/start after the appropriate
lifecycle events.
|
setLifecycleOwner
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
Apache-2.0
|
@NonNull
public FirebaseListOptions<T> build() {
assertNonNull(mSnapshots, "Snapshot array cannot be null. " +
"Call setQuery or setSnapshotArray.");
assertNonNull(mLayout, "Layout cannot be null. " +
"Call setLayout.");
return new FirebaseListOptions<>(mSnapshots, mLayout, mOwner);
}
|
Build a {@link FirebaseListOptions} from the provided arguments.
|
build
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
|
Apache-2.0
|
@NonNull
public ObservableSnapshotArray<T> getSnapshots() {
return mSnapshots;
}
|
Get the {@link ObservableSnapshotArray} to listen to.
|
getSnapshots
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
|
Apache-2.0
|
@Nullable
public LifecycleOwner getOwner() {
return mOwner;
}
|
Get the (optional) LifecycleOwner. Listening will start/stop after the appropriate lifecycle
events.
|
getOwner
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setQuery(@NonNull Query query,
@NonNull SnapshotParser<T> snapshotParser) {
assertNull(mSnapshots, ERR_SNAPSHOTS_SET);
mSnapshots = new FirebaseArray<>(query, snapshotParser);
return this;
}
|
Set the Firebase query to listen to, along with a {@link SnapshotParser} to parse
snapshots into model objects.
<p>
Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
|
setQuery
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setIndexedQuery(@NonNull Query keyQuery,
@NonNull DatabaseReference dataRef,
@NonNull SnapshotParser<T> snapshotParser) {
assertNull(mSnapshots, ERR_SNAPSHOTS_SET);
mSnapshots = new FirebaseIndexArray<>(keyQuery, dataRef, snapshotParser);
return this;
}
|
Set an indexed Firebase query to listen to, along with a {@link SnapshotParser} to parse
snapshots into model objects. Keys are identified by the {@code keyQuery} and then data
is fetched using those keys from the {@code dataRef}.
<p>
Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
|
setIndexedQuery
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
|
Apache-2.0
|
@NonNull
public FirebaseRecyclerOptions<T> build() {
assertNonNull(mSnapshots, ERR_SNAPSHOTS_NULL);
return new FirebaseRecyclerOptions<>(mSnapshots, mOwner);
}
|
Build a {@link FirebaseRecyclerOptions} from the provided arguments.
|
build
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setQuery(@NonNull Query query,
@NonNull PagingConfig config,
@NonNull Class<T> modelClass) {
return setQuery(query, config, new ClassSnapshotParser<>(modelClass));
}
|
Sets the query using a {@link ClassSnapshotParser} based
on the given class.
See {@link #setQuery(Query, PagingConfig, SnapshotParser)}.
|
setQuery
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setDiffCallback(@NonNull DiffUtil.ItemCallback<DataSnapshot> diffCallback) {
mDiffCallback = diffCallback;
return this;
}
|
Sets an optional custom {@link DiffUtil.ItemCallback} to compare
{@link T} objects.
@return this, for chaining.
|
setDiffCallback
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setLifecycleOwner(@NonNull LifecycleOwner owner) {
mOwner = owner;
return this;
}
|
Sets an optional {@link LifecycleOwner} to control the lifecycle of the adapter. Otherwise,
you must manually call {@link FirebaseRecyclerPagingAdapter#startListening()}
and {@link FirebaseRecyclerPagingAdapter#stopListening()}.
@return this, for chaining.
|
setLifecycleOwner
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
|
Apache-2.0
|
@Override
public void onChanged(@Nullable PagingData<DataSnapshot> snapshots) {
if (snapshots == null) {
return;
}
submitData(mOptions.getOwner().getLifecycle(), snapshots);
}
|
Paginated RecyclerView Adapter for a Firebase Realtime Database query.
Configured with {@link DatabasePagingOptions}.
|
onChanged
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
|
Apache-2.0
|
@NonNull
public DatabaseReference getRef(int position){
return getItem(position).getRef();
}
|
@param model the model object containing the data that should be used to populate the view.
@see #onBindViewHolder(RecyclerView.ViewHolder, int)
|
getRef
|
java
|
firebase/FirebaseUI-Android
|
database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
|
Apache-2.0
|
@Test
public void testPushIncreasesSize() throws Exception {
runAndVerify(() -> mCollectionRef.document().set(new IntegerDocument(4)),
() -> mArray.size() == (INITIAL_SIZE + 1));
}
|
Append a single document and confirm size increases by one.
|
testPushIncreasesSize
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
|
Apache-2.0
|
@Test
public void testAddToEnd() throws Exception {
final int value = 4;
runAndVerify(() -> mCollectionRef.document().set(new IntegerDocument(value)), () -> {
if (mArray.size() == (INITIAL_SIZE + 1)) {
return mArray.get(mArray.size() - 1).field == value;
}
return false;
});
}
|
Append a single document to the query and confirm that size increases by one and that the
document is added to the end of the array.
|
testAddToEnd
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
|
Apache-2.0
|
@Test
public void testAddToBeginning() throws Exception {
final int value = -1;
runAndVerify(() -> mCollectionRef.document().set(new IntegerDocument(value)), () -> {
if (mArray.size() == (INITIAL_SIZE + 1)) {
return mArray.get(0).field == value;
}
return false;
});
}
|
Append a single document to the query and confirm that size increases by one and that the
document is added to the beginning of the array.
|
testAddToBeginning
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
|
Apache-2.0
|
@NonNull
@Override
public String getId(@NonNull DocumentSnapshot snapshot) {
return snapshot.getId();
}
|
Implementation of {@link BaseCachingSnapshotParser} for {@link DocumentSnapshot}.
|
getId
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/CachingSnapshotParser.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/CachingSnapshotParser.java
|
Apache-2.0
|
@NonNull
@Override
public T parseSnapshot(@NonNull DocumentSnapshot snapshot) {
return snapshot.toObject(mModelClass);
}
|
An implementation of {@link SnapshotParser} that converts {@link DocumentSnapshot} to
a class using {@link DocumentSnapshot#toObject(Class)}.
|
parseSnapshot
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/ClassSnapshotParser.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/ClassSnapshotParser.java
|
Apache-2.0
|
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void startListening() {
if (!mSnapshots.isListening(this)) {
mSnapshots.addChangeEventListener(this);
}
}
|
Start listening for database changes and populate the adapter.
|
startListening
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerAdapter.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerAdapter.java
|
Apache-2.0
|
@NonNull
public T getItem(int position) {
return mSnapshots.get(position);
}
|
Gets the item at the specified position from the backing snapshot array.
@see ObservableSnapshotArray#get(int)
|
getItem
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerAdapter.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerAdapter.java
|
Apache-2.0
|
@Override
public int getItemCount() {
return mSnapshots.isListening(this) ? mSnapshots.size() : 0;
}
|
Gets the size of snapshots in adapter.
@return the total count of snapshots in adapter.
@see ObservableSnapshotArray#size()
|
getItemCount
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerAdapter.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerAdapter.java
|
Apache-2.0
|
@NonNull
public Builder<T> setQuery(@NonNull Query query,
@NonNull MetadataChanges changes,
@NonNull Class<T> modelClass) {
return setQuery(query, changes, new ClassSnapshotParser<>(modelClass));
}
|
Set the query to use (with options) and provide a model class to which each snapshot will
be converted.
<p>
Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
|
setQuery
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setQuery(@NonNull Query query,
@NonNull MetadataChanges changes,
@NonNull SnapshotParser<T> parser) {
assertNull(mSnapshots, ERR_SNAPSHOTS_SET);
mSnapshots = new FirestoreArray<>(query, changes, parser);
return this;
}
|
Set the query to use (with options) and provide a custom {@link SnapshotParser}.
<p>
Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
|
setQuery
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerOptions.java
|
Apache-2.0
|
@NonNull
public FirestoreRecyclerOptions<T> build() {
assertNonNull(mSnapshots, ERR_SNAPSHOTS_NULL);
return new FirestoreRecyclerOptions<>(mSnapshots, mOwner);
}
|
Build a {@link FirestoreRecyclerOptions} from the provided arguments.
|
build
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreRecyclerOptions.java
|
Apache-2.0
|
@Override
public void onChanged(@Nullable PagingData<DocumentSnapshot> snapshots) {
if (snapshots == null) {
return;
}
submitData(mOptions.getOwner().getLifecycle(), snapshots);
}
|
Paginated RecyclerView Adapter for a Cloud Firestore query.
Configured with {@link FirestorePagingOptions}.
|
onChanged
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingAdapter.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingAdapter.java
|
Apache-2.0
|
@NonNull
public Builder<T> setPagingData(@NonNull LiveData<PagingData<DocumentSnapshot>> data,
@NonNull Class<T> modelClass) {
return setPagingData(data, new ClassSnapshotParser<>(modelClass));
}
|
Directly set data using and parse with a {@link ClassSnapshotParser} based on the given
class.
<p>
Do not call this method after calling {@code setQuery}.
|
setPagingData
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setPagingData(@NonNull LiveData<PagingData<DocumentSnapshot>> pagingData,
@NonNull SnapshotParser<T> parser) {
assertNull(mPagingData, ERR_DATA_SET);
mPagingData = pagingData;
mParser = parser;
return this;
}
|
Directly set data and parse with a custom {@link SnapshotParser}.
<p>
Do not call this method after calling {@code setQuery}.
|
setPagingData
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setQuery(@NonNull Query query,
@NonNull PagingConfig config,
@NonNull Class<T> modelClass) {
return setQuery(query, Source.DEFAULT, config, modelClass);
}
|
Sets the query using {@link Source#DEFAULT} and a {@link ClassSnapshotParser} based on
the given Class.
<p>
See {@link #setQuery(Query, Source, PagingConfig, SnapshotParser)}.
|
setQuery
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setQuery(@NonNull Query query,
@NonNull PagingConfig config,
@NonNull SnapshotParser<T> parser) {
return setQuery(query, Source.DEFAULT, config, parser);
}
|
Sets the query using {@link Source#DEFAULT} and a custom {@link SnapshotParser}.
<p>
See {@link #setQuery(Query, Source, PagingConfig, SnapshotParser)}.
|
setQuery
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setQuery(@NonNull Query query,
@NonNull Source source,
@NonNull PagingConfig config,
@NonNull Class<T> modelClass) {
return setQuery(query, source, config, new ClassSnapshotParser<>(modelClass));
}
|
Sets the query using a custom {@link Source} and a {@link ClassSnapshotParser} based on
the given class.
<p>
See {@link #setQuery(Query, Source, PagingConfig, SnapshotParser)}.
|
setQuery
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
Apache-2.0
|
@NonNull
public Builder<T> setDiffCallback(@NonNull DiffUtil.ItemCallback<DocumentSnapshot> diffCallback) {
mDiffCallback = diffCallback;
return this;
}
|
Sets an optional custom {@link DiffUtil.ItemCallback} to compare {@link DocumentSnapshot}
objects.
<p>
The default implementation is {@link DefaultSnapshotDiffCallback}.
@return this, for chaining.
|
setDiffCallback
|
java
|
firebase/FirebaseUI-Android
|
firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java
|
Apache-2.0
|
public static Builder newBuilder(S3Client client, String bucketName) {
return new Builder(client, bucketName);
}
|
Creates a new builder for creating a {@link S3StateRepository}.
@param client the client instance to use for connecting to amazon s3
@param bucketName The name of the bucket to use
@return a Builder
|
newBuilder
|
java
|
togglz/togglz
|
amazon-s3/src/main/java/org/togglz/s3/S3StateRepository.java
|
https://github.com/togglz/togglz/blob/master/amazon-s3/src/main/java/org/togglz/s3/S3StateRepository.java
|
Apache-2.0
|
public Builder prefix(String keyPrefix) {
this.keyPrefix = keyPrefix == null ? "" : keyPrefix;
return this;
}
|
Optional prefixes to prepend on to each key
@param keyPrefix The prefix to use
@return this
|
prefix
|
java
|
togglz/togglz
|
amazon-s3/src/main/java/org/togglz/s3/S3StateRepository.java
|
https://github.com/togglz/togglz/blob/master/amazon-s3/src/main/java/org/togglz/s3/S3StateRepository.java
|
Apache-2.0
|
public S3StateRepository build() {
return new S3StateRepository(this);
}
|
Creates a new {@link S3StateRepository} using the current settings.
|
build
|
java
|
togglz/togglz
|
amazon-s3/src/main/java/org/togglz/s3/S3StateRepository.java
|
https://github.com/togglz/togglz/blob/master/amazon-s3/src/main/java/org/togglz/s3/S3StateRepository.java
|
Apache-2.0
|
public Builder storageClient(final Storage storageClient) {
this.storageClient = storageClient;
return this;
}
|
Specifies the cloud storage client.
@param storageClient the client instance to use for connecting to google cloud storage.
@return a {@link Builder} with current settings.
|
storageClient
|
java
|
togglz/togglz
|
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
|
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
|
Apache-2.0
|
public Builder bucketName(final String bucketName) {
this.bucketName = bucketName;
return this;
}
|
Specifies the name of the bucket.
@param bucketName Name of the bucket
@return a {@link Builder} with current settings.
|
bucketName
|
java
|
togglz/togglz
|
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
|
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
|
Apache-2.0
|
public Builder prefix(final String prefix) {
this.prefix = prefix == null ? "" : prefix;
return this;
}
|
Optional prefix to prepend on to each key.
@param prefix The prefix to use.
@return a {@link Builder} with current settings.
|
prefix
|
java
|
togglz/togglz
|
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
|
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
|
Apache-2.0
|
public GoogleCloudStorageStateRepository build() {
return new GoogleCloudStorageStateRepository(this);
}
|
Creates a new {@link GoogleCloudStorageStateRepository} using the current settings.
|
build
|
java
|
togglz/togglz
|
cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
|
https://github.com/togglz/togglz/blob/master/cloud-storage/src/main/java/org/togglz/googlecloudstorage/repository/GoogleCloudStorageStateRepository.java
|
Apache-2.0
|
default boolean isActive() {
return FeatureContext.getFeatureManager().isActive(this);
}
|
Checks whether the feature is active for the current user.
@return <code>true</code> if the feature is active, <code>false</code> otherwise
|
isActive
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/Feature.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/Feature.java
|
Apache-2.0
|
public static String getNameWithVersion() {
String version = getVersion();
return version != null ? "Togglz " + version : "Togglz";
}
|
Returns <code>Togglz</code> followed by the version if available
|
getNameWithVersion
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/Togglz.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/Togglz.java
|
Apache-2.0
|
public static String getVersion() {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = Togglz.class.getClassLoader();
}
URL url = classLoader.getResource("META-INF/maven/org.togglz/togglz-core/pom.properties");
if (url == null) {
return null;
}
try (InputStream stream = url.openStream()) {
Properties props = new Properties();
props.load(stream);
return Strings.trimToNull(props.getProperty("version"));
} catch (IOException e) {
// ignore
}
return null;
}
|
The version of Togglz or <code>null</code> if it cannot be identified
|
getVersion
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/Togglz.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/Togglz.java
|
Apache-2.0
|
protected String getPropertyName(FeatureState featureState, String parameterName) {
String propertyName = featureState.getParameter(parameterName);
if (Strings.isNotBlank(propertyName)) {
return propertyName;
}
return DEFAULT_PROPERTY_PREFIX + featureState.getFeature().name();
}
|
<p>
Returns the name of the property on which to base the activation of the feature.
</p>
<p>
This method will first attempt to use the value of the parameter with the name provided. If that does not return
a valid property name (i.e. non-blank), then a property name will be constructed using a common prefix
("{@value #DEFAULT_PROPERTY_PREFIX}") and the name of the feature.
</p>
@param featureState
the {@link FeatureState} which represents the current configuration of the feature
@param parameterName
the name of the parameter that potentially contains the property name
@return The name of the property.
|
getPropertyName
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractPropertyDrivenActivationStrategy.java
|
Apache-2.0
|
@Override
public final boolean isActive(FeatureState featureState, FeatureUser user) {
List<Token> tokens = tokenize(featureState, getTokenParameterName(), getTokenParameterTransformer());
return isActive(featureState, user, tokens);
}
|
<p>
An abstract activation strategy that is designed to support cases where a specific parameter contains comma-separated
tokens that can be negated by prefixing the value with the NOT operator ({@code !}).
</p>
<p>
{@code AbstractTokenizedActivationStrategy} makes no real assumptions on how implementations will use the tokens to
determine whether the feature is active and, instead, simply tokenizes the parameter value. It even allows for the
token values to be transformed during this process by specifying a {@link TokenTransformer}.
</p>
<p>
Implementations are responsible for honoring the negated state of any tokens. Fortunately, this is very simple to do:
</p>
<pre>
@Override
protected boolean isActive(FeatureState featureState, FeatureUser user, List<Token> tokens) {
for (Token token : tokens) {
boolean active = doSomeCheckOnTokenValue(token.getValue());
if (active != token.isNegated()) {
return true;
}
}
return false;
}
</pre>
@author Alasdair Mercer
@see #getTokenParameterName()
@see #getTokenParameterTransformer()
|
isActive
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
|
Apache-2.0
|
protected List<Token> tokenize(FeatureState featureState, String parameterName, TokenTransformer transformer) {
List<String> values = Strings.splitAndTrim(featureState.getParameter(parameterName), "[\\s,]+");
List<Token> tokens = new ArrayList<>(values.size());
for (String value : values) {
if (transformer != null) {
value = transformer.transform(value);
}
boolean negated = value.startsWith("!");
if (negated) {
value = value.substring(1);
}
tokens.add(new Token(value, negated));
}
return tokens;
}
|
<p>
Looks up and tokenizes the value of the parameter with the given name on the feature.
</p>
<p>
If {@code transformer} is not {@literal null}, it will be asked to transform each individual token value.
</p>
@param featureState
the {@link FeatureState} which represents the current configuration of the feature
@param parameterName
the name of the parameter whose value is to be tokenized
@param transformer
the {@link TokenTransformer} to be used to transform the value of each token (may be {@literal null} to use
the token values as-provided)
@return A {@code List} of {@link Token Tokens} extracted from the value of the parameter with the specified name.
|
tokenize
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
|
Apache-2.0
|
public TokenTransformer getTokenParameterTransformer() {
return null;
}
|
<p>
Returns the transformer to be used to transform the value of each {@link Token}.
</p>
<p>
By default, this method returns {@literal null}, meaning that the token values are used as-provided.
</p>
@return The {@link TokenTransformer} to be used to transform token values or {@literal null} to use the original
values.
|
getTokenParameterTransformer
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
|
Apache-2.0
|
public boolean isNegated() {
return negated;
}
|
<p>
Returns whether or not this {@link Token} is negated.
</p>
@return {@literal true} if this token is negated; otherwise {@literal false}.
|
isNegated
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
|
Apache-2.0
|
public String getValue() {
return value;
}
|
<p>
Returns the value for this {@link Token}.
</p>
@return The value.
|
getValue
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/AbstractTokenizedActivationStrategy.java
|
Apache-2.0
|
@Override
public List<ActivationStrategy> getActivationStrategies() {
return Collections.unmodifiableList(this.strategies);
}
|
Implementation of {@link ActivationStrategyProvider} that loads the strategies using the JDK {@link ServiceLoader}.
@author Jesse Kershaw
|
getActivationStrategies
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/DefaultActivationStrategyProvider.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/DefaultActivationStrategyProvider.java
|
Apache-2.0
|
public static ParameterBuilder create(String name) {
return new ParameterBuilder(name);
}
|
Creates a new builder for a parameter with the given name. The name is used to store and retrieve the parameter from the
{@link FeatureState}.
@see FeatureState#getParameter(String)
@see FeatureState#setParameter(String, String)
|
create
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
|
Apache-2.0
|
public ParameterBuilder label(String name) {
Validate.notNull(name, "name is required");
this.label = name;
return this;
}
|
A custom human readable label for the parameter. If no custom label is set, the builder will use the name of the
parameter as a label.
|
label
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
|
Apache-2.0
|
public ParameterBuilder matching(String regex) {
Validate.notNull(regex, "regex is required");
this.pattern = Pattern.compile(regex);
return this;
}
|
Sets a regular expression that must match for parameter values to be considered as valid.
|
matching
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
|
Apache-2.0
|
public ParameterBuilder optional() {
this.optional = true;
return this;
}
|
Configures the parameter to be optional.
|
optional
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
|
Apache-2.0
|
public ParameterBuilder largeText() {
this.largeText = true;
return this;
}
|
Specifies that the parameter typically has large texts as a value
|
largeText
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/activation/ParameterBuilder.java
|
Apache-2.0
|
public static void bind(FeatureManager featureManager) {
Object old = managerMap.putIfAbsent(contextClassLoader(), featureManager);
if (old != null) {
throw new IllegalStateException(
"There is already a FeatureManager associated with the context ClassLoader of the current thread!");
}
}
|
Binds the {@link FeatureManager} to the current context class loader .
|
bind
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
|
Apache-2.0
|
private static ClassLoader contextClassLoader() {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
throw new IllegalStateException("Unable to get the context class loader for the current thread!");
}
return classLoader;
}
|
Releases the {@link FeatureManager} associated with the current context class loader.
|
contextClassLoader
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/ContextClassLoaderFeatureManagerProvider.java
|
Apache-2.0
|
public static FeatureManager getFeatureManager() {
FeatureManager manager = getFeatureManagerOrNull();
if (manager != null) {
return manager;
}
throw new IllegalStateException("Could not find the FeatureManager. " +
"For web applications please verify that the TogglzFilter starts up correctly. " +
"In other deployment scenarios you will typically have to implement a FeatureManagerProvider " +
"as described in the 'Advanced Configuration' chapter of the documentation.");
}
|
Returns the {@link FeatureManager} for the current application (context class loader). The method uses the
{@link FeatureManagerProvider} SPI to find the correct {@link FeatureManager} instance. It will throw a runtime exception
if no {@link FeatureManager} can be found.
@return The {@link FeatureManager} for the application, never <code>null</code>
|
getFeatureManager
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/context/FeatureContext.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/FeatureContext.java
|
Apache-2.0
|
private static ClassLoader getContextClassLoader() {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
throw new IllegalStateException("Unable to get the context class loader for the current thread!");
}
return classLoader;
}
|
Returns the context classloader of the current thread. Throws a runtime exception if no context classloader is available.
|
getContextClassLoader
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/context/FeatureContext.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/FeatureContext.java
|
Apache-2.0
|
public static void setFeatureManager(FeatureManager featureManager) {
staticInstance = featureManager;
}
|
Sets the {@link FeatureManager} that the provider should return for calls to {@link #getFeatureManager()}.
|
setFeatureManager
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/context/StaticFeatureManagerProvider.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/StaticFeatureManagerProvider.java
|
Apache-2.0
|
public static void bind(FeatureManager featureManager) {
if (featureManager != null && threadLocal.get() != null) {
throw new IllegalStateException("bind() called for a thread that already has a FeatureManager " +
"associated with it. It's likely that the FeatureManager is not correctly removed " +
"from the thread before it is put back into the thread pool.");
}
threadLocal.set(featureManager);
}
|
Store the supplied {@link FeatureManager} in the thread context. After calling this method all calls of
{@link #getFeatureManager()} from the active thread will return this feature manager. Please don't forget to call
{@link #release()} before the thread is put back to a thread pool to prevent memory leaks.
@param featureManager The {@link FeatureManager} to store
|
bind
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/context/ThreadLocalFeatureManagerProvider.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/context/ThreadLocalFeatureManagerProvider.java
|
Apache-2.0
|
protected TogglzConfig getConfiguration(Object obj) {
if (obj instanceof Reference) {
Reference reference = (Reference) obj;
Enumeration<RefAddr> addrs = reference.getAll();
while (addrs.hasMoreElements()) {
RefAddr refAddr = addrs.nextElement();
if ("togglzConfig".equals(refAddr.getType())) {
String classname = refAddr.getContent().toString().trim();
return (TogglzConfig) createInstance(classname);
}
}
}
return null;
}
|
This class looks up the {@link TogglzConfig} to use when building the {@link FeatureManager}.
@param obj The {@link Object} obtained from {@link #getObjectInstance(Object, Name, Context, Hashtable)}.
|
getConfiguration
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/jndi/FeatureManagerObjectFactory.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/jndi/FeatureManagerObjectFactory.java
|
Apache-2.0
|
protected Object createInstance(String classname) {
// get the classloader to use
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = this.getClass().getClassLoader();
}
// create an instance of the class using the default constructor
try {
return classLoader.loadClass(classname).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new IllegalStateException(e);
}
}
|
Creates an instance of the supplied class.
|
createInstance
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/jndi/FeatureManagerObjectFactory.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/jndi/FeatureManagerObjectFactory.java
|
Apache-2.0
|
public FeatureManagerBuilder stateRepository(StateRepository stateRepository) {
this.stateRepository = stateRepository;
return this;
}
|
Use the supplied state repository for the feature manager.
|
stateRepository
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
Apache-2.0
|
public FeatureManagerBuilder featureEnum(Class<? extends Feature> featureEnum) {
return featureEnums(featureEnum);
}
|
Use the supplied feature enum class for the feature manager. Same as calling {@link #featureProvider(FeatureProvider)}
with {@link EnumBasedFeatureProvider}. Please note calling this method also set the name of the feature manager to the
simple name of the feature enum's type.
|
featureEnum
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
Apache-2.0
|
@SafeVarargs
public final FeatureManagerBuilder featureEnums(Class<? extends Feature>... featureEnum) {
this.featureProvider = new EnumBasedFeatureProvider(featureEnum);
this.name = "FeatureManager[" + featureEnum[0].getSimpleName() + "]";
return this;
}
|
Use the supplied feature enum classes for the feature manager. Same as calling {@link #featureProvider(FeatureProvider)}
with {@link EnumBasedFeatureProvider}. Please note calling this method also set the name of the feature manager to the
simple name of the first feature enum's type.
|
featureEnums
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
Apache-2.0
|
public FeatureManagerBuilder name(String name) {
this.name = name;
return this;
}
|
Sets the name of the feature manager. This name will then be available thought {@link FeatureManager#getName()}.
|
name
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
Apache-2.0
|
public FeatureManagerBuilder featureProvider(FeatureProvider featureProvider) {
this.featureProvider = featureProvider;
return this;
}
|
Sets a {@link FeatureProvider} for the feature manager. Only useful if you don't use enums to declare your features.
|
featureProvider
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
Apache-2.0
|
public FeatureManagerBuilder userProvider(UserProvider userProvider) {
this.userProvider = userProvider;
return this;
}
|
Use the supplied {@link UserProvider} for the feature manager.
|
userProvider
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
Apache-2.0
|
public FeatureManagerBuilder activationStrategyProvider(ActivationStrategyProvider strategyProvider) {
this.strategyProvider = strategyProvider;
return this;
}
|
Use the supplied {@link ActivationStrategyProvider} for the activation strategies;
|
activationStrategyProvider
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
Apache-2.0
|
public FeatureManagerBuilder activationStrategy(ActivationStrategy strategy) {
if (strategy == null) {
activationStrategyProvider(new DefaultActivationStrategyProvider());
}
if (strategyProvider instanceof DefaultActivationStrategyProvider) {
((DefaultActivationStrategyProvider) strategyProvider).addActivationStrategy(strategy);
return this;
}
throw new IllegalStateException("Adding ActivationStrategies is only allowed when using "
+ DefaultActivationStrategyProvider.class.getSimpleName());
}
|
Adds an additional {@link ActivationStrategy} to the current {@link ActivationStrategyProvider}. This currently only
works if you are using the {@link DefaultActivationStrategyProvider}.
|
activationStrategy
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
Apache-2.0
|
public FeatureManagerBuilder togglzConfig(TogglzConfig config) {
stateRepository(config.getStateRepository());
featureEnum(config.getFeatureClass());
userProvider(config.getUserProvider());
return this;
}
|
Initialize the builder with the configuration from the supplied {@link TogglzConfig} instance.
|
togglzConfig
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
Apache-2.0
|
public FeatureManager build() {
String name = (this.name != null) ? this.name : UUID.randomUUID().toString();
FeatureProvider featureProvider = this.featureProvider; // no default
StateRepository stateRepository = (this.stateRepository != null) ? this.stateRepository : new InMemoryStateRepository();
UserProvider userProvider = (this.userProvider != null) ? this.userProvider : new NoOpUserProvider();
ActivationStrategyProvider strategyProvider = (this.strategyProvider != null) ? this.strategyProvider : new DefaultActivationStrategyProvider();
Validate.notBlank(name, "No name specified");
Validate.notNull(featureProvider, "No feature provider specified");
return new DefaultFeatureManager(name, featureProvider, stateRepository, userProvider, strategyProvider);
}
|
Create the {@link FeatureManager} using the current configuration of the builder
|
build
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/manager/FeatureManagerBuilder.java
|
Apache-2.0
|
protected final void checkTogglzState() {
boolean configured = featureManager.isActive(feature);
boolean operational = delegate == active;
if (configured ^ operational) { // Less field writes -> more JIT optimisations
delegate = configured ? active : inactive;
}
}
|
Updates the internal delegate selection against the {@link Feature} state.
|
checkTogglzState
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/proxy/TogglzSwitchable.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/proxy/TogglzSwitchable.java
|
Apache-2.0
|
public static void update(Object o) {
if ( o instanceof TogglzSwitchable) {
((TogglzSwitchable<?>)o).checkTogglzState();
}
}
|
Manually update the internal delegation of a {@link TogglzSwitchable} against its
{@link Feature} state. This is intended for use with passive switching.
@param o The object to update. If null or not a {@link TogglzSwitchable}, no action is taken.
|
update
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/proxy/TogglzSwitchable.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/proxy/TogglzSwitchable.java
|
Apache-2.0
|
public FeatureState copy() {
FeatureState copy = new FeatureState(feature);
copy.setEnabled(this.enabled);
copy.setStrategyId(this.strategyId);
for (Entry<String, String> entry : this.parameters.entrySet()) {
copy.setParameter(entry.getKey(), entry.getValue());
}
return copy;
}
|
Creates a copy of this state object
|
copy
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/FeatureState.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/FeatureState.java
|
Apache-2.0
|
public Feature getFeature() {
return feature;
}
|
Returns the feature represented by this feature state.
@return The feature, never <code>null</code>
|
getFeature
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/FeatureState.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/FeatureState.java
|
Apache-2.0
|
public boolean isEnabled() {
return enabled;
}
|
Whether this feature is enabled or not.
|
isEnabled
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/FeatureState.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/FeatureState.java
|
Apache-2.0
|
public String getStrategyId() {
return strategyId;
}
|
Returns the ID of the selected activation strategy.
|
getStrategyId
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/FeatureState.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/FeatureState.java
|
Apache-2.0
|
public FeatureState setStrategyId(String strategyId) {
this.strategyId = strategyId;
return this;
}
|
Sets the selected activation strategy ID
|
setStrategyId
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/FeatureState.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/FeatureState.java
|
Apache-2.0
|
public String getParameter(String name) {
return this.parameters.get(name);
}
|
Returns the value of the given parameter. May return <code>null</code>.
|
getParameter
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/FeatureState.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/FeatureState.java
|
Apache-2.0
|
public FeatureState setParameter(String name, String value) {
if (value != null && !value.isEmpty()) {
this.parameters.put(name, value);
} else {
this.parameters.remove(name);
}
return this;
}
|
Sets a new value for the given parameter.
|
setParameter
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/FeatureState.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/FeatureState.java
|
Apache-2.0
|
public Set<String> getParameterNames() {
return this.parameters.keySet();
}
|
Returns a list of all parameter names stored in the {@link FeatureState} instance.
|
getParameterNames
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/FeatureState.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/FeatureState.java
|
Apache-2.0
|
public static FeatureState copyOf(FeatureState featureState) {
return featureState == null ? null : featureState.copy();
}
|
Returns a copy of a featureState, or <code>null</code> if the featureState is
<code>null</code>.
|
copyOf
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/FeatureState.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/FeatureState.java
|
Apache-2.0
|
public void setIterationOrder(RepositorySelector iterationOrder) {
this.iterationOrder = iterationOrder;
}
|
Sets the order this composite calls to get feature states. If not set the default iteration order
is first-in-first-out.
@param iterationOrder the iteration order
@see IterationOrder
|
setIterationOrder
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
Apache-2.0
|
public void setSetterSelection(RepositorySelector setterSelection) {
this.setterSelection = setterSelection;
}
|
Sets the selector for which state repositories to call to set a feature state. If not set the default
is the last repository in this composite.
@param setterSelection the selector
@see SetterSelection
|
setSetterSelection
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
Apache-2.0
|
@Override
public FeatureState getFeatureState(Feature feature) {
for (StateRepository repository : iterationOrder.getSelected(repositories)) {
FeatureState featureState = repository.getFeatureState(feature);
if (featureState != null) {
return featureState;
}
}
return null;
}
|
Returns the first non-null feature state as determined by the current iteration order.
@see #setIterationOrder(RepositorySelector)
|
getFeatureState
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
Apache-2.0
|
@Override
public void setFeatureState(FeatureState featureState) {
for (StateRepository repository : setterSelection.getSelected(repositories)) {
repository.setFeatureState(featureState);
}
}
|
Sets the feature state on the repositories returned by the current setter selection.
@see #setSetterSelection(RepositorySelector)
|
setFeatureState
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
Apache-2.0
|
public List<StateRepository> getSelected(List<StateRepository> from) {
return new ArrayList<>(from);
}
|
The iteration order is the same as what was specified when constructing this composite.
|
getSelected
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
Apache-2.0
|
public List<StateRepository> getSelected(List<StateRepository> from) {
List<StateRepository> result = new ArrayList<>(from);
Collections.reverse(result);
return result;
}
|
The iteration order is the revers of what was specified when constructing this composite.
|
getSelected
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
Apache-2.0
|
public List<StateRepository> getSelected(List<StateRepository> from) {
return get(from, 0);
}
|
Use the first repository in this composite to set the state.
|
getSelected
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
Apache-2.0
|
public List<StateRepository> getSelected(List<StateRepository> from) {
return get(from, from.size() - 1);
}
|
Use the last repository in this composite to set the state.
|
getSelected
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/composite/CompositeStateRepository.java
|
Apache-2.0
|
protected void migrateSchema() {
try {
Connection connection = dataSource.getConnection();
try {
beforeSchemaMigration(connection);
SchemaUpdater updater = new SchemaUpdater(connection, tableName, serializer);
if (!updater.doesTableExist()) {
updater.migrateToVersion1();
}
if (updater.isSchemaVersion1()) {
updater.migrateToVersion2();
}
if (usePostgresTextColumns && updater.isPostgres()) {
updater.migrateToTextColumns();
}
afterSchemaMigration(connection);
} finally {
DbUtils.closeQuietly(connection);
}
} catch (SQLException e) {
throw new IllegalStateException("Failed to migrate the database schema", e);
}
}
|
Method for creating/migrating the database schema
|
migrateSchema
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
Apache-2.0
|
@SuppressWarnings("unused")
protected void beforeSchemaMigration(Connection connection) {
// overwrite me
}
|
Method called <strong>before</strong> the database schema migration is performed.
|
beforeSchemaMigration
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
Apache-2.0
|
public static Builder newBuilder(DataSource dataSource) {
return new Builder(dataSource);
}
|
Creates a new builder for creating a {@link JDBCStateRepository}.
@param dataSource the {@link DataSource} Togglz should use to obtain JDBC connections
|
newBuilder
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
Apache-2.0
|
public Builder tableName(String tableName) {
this.tableName = tableName;
return this;
}
|
Sets the table name to use for the Togglz feature state table. The default name is <code>TOGGLZ</code>.
@param tableName The database table name
|
tableName
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
Apache-2.0
|
public Builder serializer(MapSerializer serializer) {
this.serializer = serializer;
return this;
}
|
The {@link MapSerializer} for storing parameters. By default the repository will use
{@link DefaultMapSerializer#multiline()}.
@param serializer The serializer to use
|
serializer
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
Apache-2.0
|
public Builder createTable(boolean createTable) {
this.createTable = createTable;
return this;
}
|
If set to <code>true</code>, the table will be automatically created if it is missing. The default is
<code>true</code>.
@param createTable <code>true</code> if the table should be created automatically
|
createTable
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
Apache-2.0
|
public Builder usePostgresTextColumns(boolean usePostgresTextColumns) {
this.usePostgresTextColumns = usePostgresTextColumns;
return this;
}
|
If set to <code>true</code>, createTable being <code>true</code>, and running on PostgreSQL,
the table will use the TEXT column type where possible. The default is <code>false</code>.
@param usePostgresTextColumns <code>true</code> if PostgreSQL's TEXT column type should be used
|
usePostgresTextColumns
|
java
|
togglz/togglz
|
core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/JDBCStateRepository.java
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.