code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
public Set<String> getKeysStartingWith(String prefix) { Set<String> result = new HashSet<>(); Enumeration<?> keys = values.propertyNames(); while (keys.hasMoreElements()) { String key = keys.nextElement().toString(); if (key.startsWith(prefix)) { result.a...
Please note that this class is NOT thread-safe.
getKeysStartingWith
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/file/ReloadablePropertiesFile.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/file/ReloadablePropertiesFile.java
Apache-2.0
public PropertySource.Editor getEditor() { return new PropertyFileEditor(values); }
Please note that this class is NOT thread-safe.
getEditor
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/file/ReloadablePropertiesFile.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/file/ReloadablePropertiesFile.java
Apache-2.0
private void write(Properties newValues) { try { FileOutputStream fos = new FileOutputStream(file); newValues.store(fos, null); fos.flush(); fos.close(); } catch (IOException e) { throw new IllegalStateException("Failed to write new values", ...
Please note that this class is NOT thread-safe.
write
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/file/ReloadablePropertiesFile.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/file/ReloadablePropertiesFile.java
Apache-2.0
public void setValue(String key, String value) { if (value != null) { newValues.setProperty(key, value); } else { newValues.remove(key); } }
Please note that this class is NOT thread-safe.
setValue
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/file/ReloadablePropertiesFile.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/file/ReloadablePropertiesFile.java
Apache-2.0
public void removeKeysStartingWith(String prefix) { newValues.entrySet().removeIf(entry -> entry.getKey().toString().startsWith(prefix)); }
Please note that this class is NOT thread-safe.
removeKeysStartingWith
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/file/ReloadablePropertiesFile.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/file/ReloadablePropertiesFile.java
Apache-2.0
protected void migrateSchema() { try { Connection connection = dataSource.getConnection(); try { beforeSchemaMigration(connection); SchemaUpdater updater = new SchemaUpdater(connection, tableName, serializer); if (!updater.doesTableExis...
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
@SuppressWarnings("unused") protected void afterSchemaMigration(Connection connection) { // overwrite me }
Method called <strong>after</strong> the database schema migration has been performed.
afterSchemaMigration
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
@Override public FeatureState getFeatureState(Feature feature) { try { Connection connection = dataSource.getConnection(); try { String sql = "SELECT FEATURE_ENABLED, STRATEGY_ID, STRATEGY_PARAMS FROM %TABLE% WHERE FEATURE_NAME = ?"; PreparedStateme...
Method called <strong>after</strong> the database schema migration has been performed.
getFeatureState
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
@Override public void setFeatureState(FeatureState featureState) { try { Connection connection = dataSource.getConnection(); try { int updatedRows = 0; /* * First try to update an existing row */ St...
Method called <strong>after</strong> the database schema migration has been performed.
setFeatureState
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
protected String insertTableName(String s) { return s.replace("%TABLE%", tableName); }
Method called <strong>after</strong> the database schema migration has been performed.
insertTableName
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
public JDBCStateRepository build() { return new JDBCStateRepository(this); }
Creates a {@link JDBCStateRepository} from the current configuration
build
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
protected boolean doesTableExist() throws SQLException { return isSuccessful("SELECT * FROM %TABLE%"); }
Class that creates and migrates the database table required by {@link JDBCStateRepository}. @author Christian Kaltepoth
doesTableExist
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
Apache-2.0
protected void migrateToVersion1() throws SQLException { execute("CREATE TABLE %TABLE% (FEATURE_NAME VARCHAR(100) PRIMARY KEY, FEATURE_ENABLED INTEGER, FEATURE_USERS VARCHAR(2000))"); }
Class that creates and migrates the database table required by {@link JDBCStateRepository}. @author Christian Kaltepoth
migrateToVersion1
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
Apache-2.0
protected boolean isSchemaVersion1() throws SQLException { return columnExists(Columns.FEATURE_NAME) && !columnExists(Columns.STRATEGY_ID); }
Class that creates and migrates the database table required by {@link JDBCStateRepository}. @author Christian Kaltepoth
isSchemaVersion1
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
Apache-2.0
protected void migrateToVersion2() throws SQLException { /* * step 1: add new columns */ execute("ALTER TABLE %TABLE% ADD STRATEGY_ID VARCHAR(200)"); execute("ALTER TABLE %TABLE% ADD STRATEGY_PARAMS VARCHAR(2000)"); /* * step 2: migrate the existing data ...
Class that creates and migrates the database table required by {@link JDBCStateRepository}. @author Christian Kaltepoth
migrateToVersion2
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
Apache-2.0
protected boolean isPostgres() throws SQLException { String dbName = connection.getMetaData().getDatabaseProductName(); return "PostgreSQL".equals(dbName); }
Class that creates and migrates the database table required by {@link JDBCStateRepository}. @author Christian Kaltepoth
isPostgres
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
Apache-2.0
protected void migrateToTextColumns() throws SQLException { execute(substitute("ALTER TABLE %TABLE% " + "ALTER COLUMN FEATURE_NAME TYPE TEXT," + "ALTER COLUMN STRATEGY_ID TYPE TEXT," + "ALTER COLUMN STRATEGY_PARAMS TYPE TEXT" )); }
Class that creates and migrates the database table required by {@link JDBCStateRepository}. @author Christian Kaltepoth
migrateToTextColumns
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
Apache-2.0
private boolean columnExists(String column) throws SQLException { return isSuccessful("SELECT " + column + " FROM %TABLE%"); }
Returns <code>true</code> if the given column exists in the features table. @throws SQLException
columnExists
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
Apache-2.0
private boolean isSuccessful(String sql) throws SQLException { Statement statement = connection.createStatement(); try { statement.execute(substitute(sql)); } catch (SQLException e) { return false; } finally { DbUtils.closeQuietly(statement); }...
Returns <code>true</code> if the supplied statement returned without any error
isSuccessful
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
Apache-2.0
private String substitute(String s) { return s.replace("%TABLE%", tableName); }
Replaces <code>%TABLE%</code> with the table name configured.
substitute
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/jdbc/SchemaUpdater.java
Apache-2.0
@Override public FeatureState getFeatureState(Feature feature) { return FeatureState.copyOf(states.get(feature.name())); }
A very simply implementation of {@link StateRepository} entirely on memory. This class is typically only used for integration tests or at development time. @author Christian Kaltepoth
getFeatureState
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/mem/InMemoryStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/mem/InMemoryStateRepository.java
Apache-2.0
@Override public void setFeatureState(FeatureState featureState) { states.put(featureState.getFeature().name(), FeatureState.copyOf(featureState)); }
A very simply implementation of {@link StateRepository} entirely on memory. This class is typically only used for integration tests or at development time. @author Christian Kaltepoth
setFeatureState
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/mem/InMemoryStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/mem/InMemoryStateRepository.java
Apache-2.0
public FeatureState getFeatureState(Feature feature) { lock.lock(); try { // update file if changed propertySource.reloadIfUpdated(); // if we got this one, the feature is present in the repository String enabledAsStr = propertySource.getValue(getEnabledP...
This implementation of {@link StateRepository} stores the state of features in a {@link Properties} format. The properties are managed through an implementation of {@link PropertySource} to manage the actual source of the property values. <p> The file format has changed since version 2.0.0 because of the new extendable...
getFeatureState
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
Apache-2.0
public void setFeatureState(FeatureState featureState) { lock.lock(); try { // update file if changed propertySource.reloadIfUpdated(); Feature feature = featureState.getFeature(); PropertySource.Editor editor = propertySource.getEditor(); //...
This implementation of {@link StateRepository} stores the state of features in a {@link Properties} format. The properties are managed through an implementation of {@link PropertySource} to manage the actual source of the property values. <p> The file format has changed since version 2.0.0 because of the new extendable...
setFeatureState
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
Apache-2.0
private static String getEnabledPropertyName(Feature feature) { return feature.name(); }
This implementation of {@link StateRepository} stores the state of features in a {@link Properties} format. The properties are managed through an implementation of {@link PropertySource} to manage the actual source of the property values. <p> The file format has changed since version 2.0.0 because of the new extendable...
getEnabledPropertyName
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
Apache-2.0
private static String getStrategyPropertyName(Feature feature) { return feature.name() + ".strategy"; }
This implementation of {@link StateRepository} stores the state of features in a {@link Properties} format. The properties are managed through an implementation of {@link PropertySource} to manage the actual source of the property values. <p> The file format has changed since version 2.0.0 because of the new extendable...
getStrategyPropertyName
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
Apache-2.0
private static String getParameterPropertyName(Feature feature, String parameter) { return feature.name() + ".param." + parameter; }
This implementation of {@link StateRepository} stores the state of features in a {@link Properties} format. The properties are managed through an implementation of {@link PropertySource} to manage the actual source of the property values. <p> The file format has changed since version 2.0.0 because of the new extendable...
getParameterPropertyName
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
Apache-2.0
private static String getUsersPropertyName(Feature feature) { return feature.name() + ".users"; }
This implementation of {@link StateRepository} stores the state of features in a {@link Properties} format. The properties are managed through an implementation of {@link PropertySource} to manage the actual source of the property values. <p> The file format has changed since version 2.0.0 because of the new extendable...
getUsersPropertyName
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
Apache-2.0
private static boolean isTrue(String s) { return s != null && ("true".equalsIgnoreCase(s.trim()) || "yes".equalsIgnoreCase(s.trim()) || "enabled".equalsIgnoreCase(s.trim()) || "enable".equalsIgnoreCase(s.trim())); }
This implementation of {@link StateRepository} stores the state of features in a {@link Properties} format. The properties are managed through an implementation of {@link PropertySource} to manage the actual source of the property values. <p> The file format has changed since version 2.0.0 because of the new extendable...
isTrue
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
Apache-2.0
private static List<String> toList(String input) { return Strings.splitAndTrim(input, ","); }
This implementation of {@link StateRepository} stores the state of features in a {@link Properties} format. The properties are managed through an implementation of {@link PropertySource} to manage the actual source of the property values. <p> The file format has changed since version 2.0.0 because of the new extendable...
toList
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/property/PropertyBasedStateRepository.java
Apache-2.0
public static DefaultMapSerializer singleline() { return new DefaultMapSerializer(false); }
Creates a new instance of the {@link DefaultMapSerializer}.
singleline
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/util/DefaultMapSerializer.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/util/DefaultMapSerializer.java
Apache-2.0
public static DefaultMapSerializer multiline() { return new DefaultMapSerializer(true); }
Creates a new instance of the {@link DefaultMapSerializer}.
multiline
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/util/DefaultMapSerializer.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/util/DefaultMapSerializer.java
Apache-2.0
public static DefaultMapSerializer multiline(String lineSeparator) { return new DefaultMapSerializer(true, lineSeparator); }
Creates a new instance of the {@link DefaultMapSerializer}.
multiline
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/util/DefaultMapSerializer.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/util/DefaultMapSerializer.java
Apache-2.0
@Override public String serialize(Map<String, String> map) { try { if (map.isEmpty()) { return ""; } // the format is based on the properties output format Properties props = new Properties(); props.putAll(map); Write...
Creates a new instance of the {@link DefaultMapSerializer}.
serialize
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/util/DefaultMapSerializer.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/util/DefaultMapSerializer.java
Apache-2.0
@Override public Map<String, String> deserialize(String s) { try { String input = multiline ? s : s.replace('&', '\n'); if (input == null || input.isEmpty()) { return Collections.emptyMap(); } Properties props = new Properties(); ...
Creates a new instance of the {@link DefaultMapSerializer}.
deserialize
java
togglz/togglz
core/src/main/java/org/togglz/core/repository/util/DefaultMapSerializer.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/repository/util/DefaultMapSerializer.java
Apache-2.0
@Override public FeatureUser getCurrentUser() { return null; }
This implementation of {@link UserProvider} can be used if user-dependent feature toggling isn't used at all. @author Christian Kaltepoth
getCurrentUser
java
togglz/togglz
core/src/main/java/org/togglz/core/user/NoOpUserProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/user/NoOpUserProvider.java
Apache-2.0
@Override public String getName() { return name; }
Constructor of {@link DefaultFeatureManager}. @param name The name of the user @param featureAdmin <code>true</code> if the user is a feature admin
getName
java
togglz/togglz
core/src/main/java/org/togglz/core/user/SimpleFeatureUser.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/user/SimpleFeatureUser.java
Apache-2.0
@Override public boolean isFeatureAdmin() { return featureAdmin; }
Constructor of {@link DefaultFeatureManager}. @param name The name of the user @param featureAdmin <code>true</code> if the user is a feature admin
isFeatureAdmin
java
togglz/togglz
core/src/main/java/org/togglz/core/user/SimpleFeatureUser.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/user/SimpleFeatureUser.java
Apache-2.0
@Override public Object getAttribute(String name) { return attributes.get(name); }
Constructor of {@link DefaultFeatureManager}. @param name The name of the user @param featureAdmin <code>true</code> if the user is a feature admin
getAttribute
java
togglz/togglz
core/src/main/java/org/togglz/core/user/SimpleFeatureUser.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/user/SimpleFeatureUser.java
Apache-2.0
public SimpleFeatureUser setAttribute(String name, Object value) { if (value != null) { attributes.put(name, value); } else { attributes.remove(name); } return this; }
This method can be used to set attributes of the user. @param name The name of the attribute @param value The value of the attribute @return <code>this</code> for fluent object creation
setAttribute
java
togglz/togglz
core/src/main/java/org/togglz/core/user/SimpleFeatureUser.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/user/SimpleFeatureUser.java
Apache-2.0
@Override public FeatureUser getCurrentUser() { return user; }
A very simple implementation of {@link UserProvider} which always returns the supplied user.
getCurrentUser
java
togglz/togglz
core/src/main/java/org/togglz/core/user/SingleUserProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/user/SingleUserProvider.java
Apache-2.0
@Override public FeatureUser getCurrentUser() { AccessControlContext acc = AccessController.getContext(); if (acc != null) { Subject subject = Subject.getSubject(acc); if (subject != null) { Iterator<Principal> iter = subject.getPrincipals().iterator(); ...
This implementation supports looking up the current user the JAAS AccessControlContext. The class currently doesn't support determining whether a user is a feature admin and therefore always sets it to false. Overriding {@link #isFeatureAdmin(String)} allows to change the default behavior. @author Christian Kaltepoth
getCurrentUser
java
togglz/togglz
core/src/main/java/org/togglz/core/user/jaas/JAASUserProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/user/jaas/JAASUserProvider.java
Apache-2.0
protected boolean isFeatureAdmin(Principal principal) { return false; }
Checks if the supplied user is a feature admin. The default implementation always returns <code>false</code>. Users can overwrite this method to implement a different behavior. @param principal The principal @return <code>true</code> for feature admins, <code>false</code> otherwise
isFeatureAdmin
java
togglz/togglz
core/src/main/java/org/togglz/core/user/jaas/JAASUserProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/user/jaas/JAASUserProvider.java
Apache-2.0
public static void bind(FeatureUser featureUser) { if (featureUser != null && threadLocal.get() != null) { throw new IllegalStateException("setFeatureUser() called for a " + "thread that already has one associated with it. It's likely that the FeatureUser " + ...
Store the supplied FeatureUser in the thread context. After calling this method all calls of {@link #getCurrentUser()} from the active thread will return this feature user. Please don't forget to call {@link #release()} before the thread is put back to a thread pool to prevent memory leaks. @param featureUser The feat...
bind
java
togglz/togglz
core/src/main/java/org/togglz/core/user/thread/ThreadLocalUserProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/user/thread/ThreadLocalUserProvider.java
Apache-2.0
@Override public FeatureUser getCurrentUser() { return threadLocal.get(); }
Removes the user associated with the current thread from the thread's context. It's required to always call this method before a thread is put back to a thread pool.
getCurrentUser
java
togglz/togglz
core/src/main/java/org/togglz/core/user/thread/ThreadLocalUserProvider.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/user/thread/ThreadLocalUserProvider.java
Apache-2.0
private static int hash(int h) { // Spread bits to regularize both segment and index locations, // using variant of single-word Wang/Jenkins hash. h += (h << 15) ^ 0xffffcd7d; h ^= (h >>> 10); h += (h << 3); h ^= (h >>> 6); h += (h << 2) + (h << 14); ...
Applies a supplemental hash function to a given hashCode, which defends against poor quality hash functions. This is critical because ConcurrentReferenceHashMap uses power-of-two length hash tables, that otherwise encounter collisions for hashCodes that do not differ in lower or upper bits.
hash
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
final Segment<K,V> segmentFor(int hash) { return segments[(hash >>> segmentShift) & segmentMask]; }
Returns the segment that should be used for key with given hash @param hash the hash code for the key @return the segment
segmentFor
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
private int hashOf(Object key) { return hash(identityComparisons ? System.identityHashCode(key) : key.hashCode()); }
Returns the segment that should be used for key with given hash @param hash the hash code for the key @return the segment
hashOf
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public final int keyHash() { return hash; }
A weak-key reference which stores the key hash needed for reclamation.
keyHash
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public final Object keyRef() { return this; }
A weak-key reference which stores the key hash needed for reclamation.
keyRef
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public final int keyHash() { return hash; }
A soft-key reference which stores the key hash needed for reclamation.
keyHash
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public final Object keyRef() { return this; }
A soft-key reference which stores the key hash needed for reclamation.
keyRef
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public final int keyHash() { return hash; }
A soft-key reference which stores the key hash needed for reclamation.
keyHash
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public final Object keyRef() { return keyRef; }
A soft-key reference which stores the key hash needed for reclamation.
keyRef
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public final int keyHash() { return hash; }
A soft-key reference which stores the key hash needed for reclamation.
keyHash
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public final Object keyRef() { return keyRef; }
A soft-key reference which stores the key hash needed for reclamation.
keyRef
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
final Object newKeyReference(K key, ReferenceType keyType, ReferenceQueue<Object> refQueue) { if (keyType == ReferenceType.WEAK) return new WeakKeyReference<K>(key, hash, refQueue); if (keyType == ReferenceType.SOFT) return new...
ConcurrentReferenceHashMap list entry. Note that this is never exported out as a user-visible Map.Entry. Because the value field is volatile, not final, it is legal wrt the Java Memory Model for an unsynchronized reader to see null instead of initial value when read via a data race. Although a reordering leading to t...
newKeyReference
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
final Object newValueReference(V value, ReferenceType valueType, ReferenceQueue<Object> refQueue) { if (valueType == ReferenceType.WEAK) return new WeakValueReference<V>(value, keyRef, hash, refQueue); if (valueType == ReferenceType.SOFT) ...
ConcurrentReferenceHashMap list entry. Note that this is never exported out as a user-visible Map.Entry. Because the value field is volatile, not final, it is legal wrt the Java Memory Model for an unsynchronized reader to see null instead of initial value when read via a data race. Although a reordering leading to t...
newValueReference
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
@SuppressWarnings("unchecked") final K key() { if (keyRef instanceof KeyReference) return ((Reference<K>)keyRef).get(); return (K) keyRef; }
ConcurrentReferenceHashMap list entry. Note that this is never exported out as a user-visible Map.Entry. Because the value field is volatile, not final, it is legal wrt the Java Memory Model for an unsynchronized reader to see null instead of initial value when read via a data race. Although a reordering leading to t...
key
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
final V value() { return dereferenceValue(valueRef); }
ConcurrentReferenceHashMap list entry. Note that this is never exported out as a user-visible Map.Entry. Because the value field is volatile, not final, it is legal wrt the Java Memory Model for an unsynchronized reader to see null instead of initial value when read via a data race. Although a reordering leading to t...
value
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
@SuppressWarnings("unchecked") final V dereferenceValue(Object value) { if (value instanceof KeyReference) return ((Reference<V>)value).get(); return (V) value; }
ConcurrentReferenceHashMap list entry. Note that this is never exported out as a user-visible Map.Entry. Because the value field is volatile, not final, it is legal wrt the Java Memory Model for an unsynchronized reader to see null instead of initial value when read via a data race. Although a reordering leading to t...
dereferenceValue
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
final void setValue(V value, ReferenceType valueType, ReferenceQueue<Object> refQueue) { this.valueRef = newValueReference(value, valueType, refQueue); }
ConcurrentReferenceHashMap list entry. Note that this is never exported out as a user-visible Map.Entry. Because the value field is volatile, not final, it is legal wrt the Java Memory Model for an unsynchronized reader to see null instead of initial value when read via a data race. Although a reordering leading to t...
setValue
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
@SuppressWarnings("unchecked") static final <K,V> HashEntry<K,V>[] newArray(int i) { return new HashEntry[i]; }
ConcurrentReferenceHashMap list entry. Note that this is never exported out as a user-visible Map.Entry. Because the value field is volatile, not final, it is legal wrt the Java Memory Model for an unsynchronized reader to see null instead of initial value when read via a data race. Although a reordering leading to t...
newArray
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
@SuppressWarnings("unchecked") static final <K,V> Segment<K,V>[] newArray(int i) { return new Segment[i]; }
The collected weak-key reference queue for this segment. This should be (re)initialized whenever table is assigned,
newArray
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
private boolean keyEq(Object src, Object dest) { return identityComparisons ? src == dest : src.equals(dest); }
The collected weak-key reference queue for this segment. This should be (re)initialized whenever table is assigned,
keyEq
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
void setTable(HashEntry<K,V>[] newTable) { threshold = (int)(newTable.length * loadFactor); table = newTable; refQueue = new ReferenceQueue<Object>(); }
Sets table to new HashEntry array. Call only while holding lock or in constructor.
setTable
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
HashEntry<K,V> getFirst(int hash) { HashEntry<K,V>[] tab = table; return tab[hash & (tab.length - 1)]; }
Returns properly casted first entry of bin for given hash.
getFirst
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
HashEntry<K,V> newHashEntry(K key, int hash, HashEntry<K, V> next, V value) { return new HashEntry<K,V>(key, hash, next, value, keyType, valueType, refQueue); }
Returns properly casted first entry of bin for given hash.
newHashEntry
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
V readValueUnderLock(HashEntry<K,V> e) { lock(); try { removeStale(); return e.value(); } finally { unlock(); } }
Reads value field of an entry under lock. Called if value field ever appears to be null. This is possible only if a compiler happens to reorder a HashEntry initialization with its table assignment, which is legal under memory model but is not known to ever occur.
readValueUnderLock
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
V get(Object key, int hash) { if (count != 0) { // read-volatile HashEntry<K,V> e = getFirst(hash); while (e != null) { if (e.hash == hash && keyEq(key, e.key())) { Object opaque = e.valueRef; if (opaque != n...
Reads value field of an entry under lock. Called if value field ever appears to be null. This is possible only if a compiler happens to reorder a HashEntry initialization with its table assignment, which is legal under memory model but is not known to ever occur.
get
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
boolean containsKey(Object key, int hash) { if (count != 0) { // read-volatile HashEntry<K,V> e = getFirst(hash); while (e != null) { if (e.hash == hash && keyEq(key, e.key())) return true; e = e.next; ...
Reads value field of an entry under lock. Called if value field ever appears to be null. This is possible only if a compiler happens to reorder a HashEntry initialization with its table assignment, which is legal under memory model but is not known to ever occur.
containsKey
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
boolean containsValue(Object value) { if (count != 0) { // read-volatile HashEntry<K,V>[] tab = table; int len = tab.length; for (int i = 0 ; i < len; i++) { for (HashEntry<K,V> e = tab[i]; e != null; e = e.next) { O...
Reads value field of an entry under lock. Called if value field ever appears to be null. This is possible only if a compiler happens to reorder a HashEntry initialization with its table assignment, which is legal under memory model but is not known to ever occur.
containsValue
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
boolean replace(K key, int hash, V oldValue, V newValue) { lock(); try { removeStale(); HashEntry<K,V> e = getFirst(hash); while (e != null && (e.hash != hash || !keyEq(key, e.key()))) e = e.next; boolean replac...
Reads value field of an entry under lock. Called if value field ever appears to be null. This is possible only if a compiler happens to reorder a HashEntry initialization with its table assignment, which is legal under memory model but is not known to ever occur.
replace
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
V replace(K key, int hash, V newValue) { lock(); try { removeStale(); HashEntry<K,V> e = getFirst(hash); while (e != null && (e.hash != hash || !keyEq(key, e.key()))) e = e.next; V oldValue = null; ...
Reads value field of an entry under lock. Called if value field ever appears to be null. This is possible only if a compiler happens to reorder a HashEntry initialization with its table assignment, which is legal under memory model but is not known to ever occur.
replace
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
V put(K key, int hash, V value, boolean onlyIfAbsent) { lock(); try { removeStale(); int c = count; if (c++ > threshold) {// ensure capacity int reduced = rehash(); if (reduced > 0) // adjust from possible w...
Reads value field of an entry under lock. Called if value field ever appears to be null. This is possible only if a compiler happens to reorder a HashEntry initialization with its table assignment, which is legal under memory model but is not known to ever occur.
put
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
int rehash() { HashEntry<K,V>[] oldTable = table; int oldCapacity = oldTable.length; if (oldCapacity >= MAXIMUM_CAPACITY) return 0; /* * Reclassify nodes in each list to new Map. Because we are * using power-of-two expansion, th...
Reads value field of an entry under lock. Called if value field ever appears to be null. This is possible only if a compiler happens to reorder a HashEntry initialization with its table assignment, which is legal under memory model but is not known to ever occur.
rehash
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
V remove(Object key, int hash, Object value, boolean refRemove) { lock(); try { if (!refRemove) removeStale(); int c = count - 1; HashEntry<K,V>[] tab = table; int index = hash & (tab.length - 1); ...
Remove; match on key only if value null, else match both.
remove
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
final void removeStale() { KeyReference ref; while ((ref = (KeyReference) refQueue.poll()) != null) { remove(ref.keyRef(), ref.keyHash(), null, true); } }
Remove; match on key only if value null, else match both.
removeStale
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
void clear() { if (count != 0) { lock(); try { HashEntry<K,V>[] tab = table; for (int i = 0; i < tab.length ; i++) tab[i] = null; ++modCount; // replace the reference queue...
Remove; match on key only if value null, else match both.
clear
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public boolean isEmpty() { final Segment<K,V>[] segments = this.segments; /* * We keep track of per-segment modCounts to avoid ABA * problems in which an element in one segment was added and * in another removed during traversal, in which case the * table was never ac...
Returns <tt>true</tt> if this map contains no key-value mappings. @return <tt>true</tt> if this map contains no key-value mappings
isEmpty
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public int size() { final Segment<K,V>[] segments = this.segments; long sum = 0; long check = 0; int[] mc = new int[segments.length]; // Try a few times to get accurate count. On failure due to // continuous async changes in table, resort to locking. for (int k = ...
Returns the number of key-value mappings in this map. If the map contains more than <tt>Integer.MAX_VALUE</tt> elements, returns <tt>Integer.MAX_VALUE</tt>. @return the number of key-value mappings in this map
size
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public V get(Object key) { int hash = hashOf(key); return segmentFor(hash).get(key, hash); }
Returns the value to which the specified key is mapped, or {@code null} if this map contains no mapping for the key. <p>More formally, if this map contains a mapping from a key {@code k} to a value {@code v} such that {@code key.equals(k)}, then this method returns {@code v}; otherwise it returns {@code null}. (There...
get
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public boolean containsKey(Object key) { int hash = hashOf(key); return segmentFor(hash).containsKey(key, hash); }
Tests if the specified object is a key in this table. @param key possible key @return <tt>true</tt> if and only if the specified object is a key in this table, as determined by the <tt>equals</tt> method; <tt>false</tt> otherwise. @throws NullPointerException if the specified key is null
containsKey
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public boolean containsValue(Object value) { if (value == null) throw new NullPointerException(); // See explanation of modCount use above final Segment<K,V>[] segments = this.segments; int[] mc = new int[segments.length]; // Try a few times without locking ...
Returns <tt>true</tt> if this map maps one or more keys to the specified value. Note: This method requires a full internal traversal of the hash table, and so is much slower than method <tt>containsKey</tt>. @param value value whose presence in this map is to be tested @return <tt>true</tt> if this map maps one or mor...
containsValue
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public boolean contains(Object value) { return containsValue(value); }
Legacy method testing if some key maps into the specified value in this table. This method is identical in functionality to {@link #containsValue}, and exists solely to ensure full compatibility with class {@link java.util.Hashtable}, which supported this method prior to introduction of the Java Collections framework....
contains
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public V putIfAbsent(K key, V value) { if (value == null) throw new NullPointerException(); int hash = hashOf(key); return segmentFor(hash).put(key, hash, value, true); }
{@inheritDoc} @return the previous value associated with the specified key, or <tt>null</tt> if there was no mapping for the key @throws NullPointerException if the specified key or value is null
putIfAbsent
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public void putAll(Map<? extends K, ? extends V> m) { for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) put(e.getKey(), e.getValue()); }
Copies all of the mappings from the specified map to this one. These mappings replace any mappings that this map had for any of the keys currently in the specified map. @param m mappings to be stored in this map
putAll
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public V remove(Object key) { int hash = hashOf(key); return segmentFor(hash).remove(key, hash, null, false); }
Removes the key (and its corresponding value) from this map. This method does nothing if the key is not in the map. @param key the key that needs to be removed @return the previous value associated with <tt>key</tt>, or <tt>null</tt> if there was no mapping for <tt>key</tt> @throws NullPointerException if the...
remove
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public boolean remove(Object key, Object value) { int hash = hashOf(key); if (value == null) return false; return segmentFor(hash).remove(key, hash, value, false) != null; }
{@inheritDoc} @throws NullPointerException if the specified key is null
remove
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public boolean replace(K key, V oldValue, V newValue) { if (oldValue == null || newValue == null) throw new NullPointerException(); int hash = hashOf(key); return segmentFor(hash).replace(key, hash, oldValue, newValue); }
{@inheritDoc} @throws NullPointerException if any of the arguments are null
replace
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public V replace(K key, V value) { if (value == null) throw new NullPointerException(); int hash = hashOf(key); return segmentFor(hash).replace(key, hash, value); }
{@inheritDoc} @return the previous value associated with the specified key, or <tt>null</tt> if there was no mapping for the key @throws NullPointerException if the specified key or value is null
replace
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public void clear() { for (int i = 0; i < segments.length; ++i) segments[i].clear(); }
Removes all of the mappings from this map.
clear
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public void purgeStaleEntries() { for (int i = 0; i < segments.length; ++i) segments[i].removeStale(); }
Removes any stale entries whose keys have been finalized. Use of this method is normally not necessary since stale entries are automatically removed lazily, when blocking operations are required. However, there are some cases where this operation should be performed eagerly, such as cleaning up old references to a Clas...
purgeStaleEntries
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0
public Set<K> keySet() { Set<K> ks = keySet; return (ks != null) ? ks : (keySet = new KeySet()); }
Returns a {@link Set} view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding mapping from this map, via the <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, <tt>removeAll</tt>,...
keySet
java
togglz/togglz
core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
https://github.com/togglz/togglz/blob/master/core/src/main/java/org/togglz/core/util/ConcurrentReferenceHashMap.java
Apache-2.0