
net.customware.license.support.simple.SimpleLicenseContent Maven / Gradle / Ivy
The newest version!
package net.customware.license.support.simple;
import java.util.Map;
import de.schlichtherle.license.LicenseContent;
public class SimpleLicenseContent extends LicenseContent {
public SimpleLicenseContent() {
}
/**
* Sets an attribute for the specified type. Each type can only have one
* attribute set for it for the lifespan of the instance. The provided value
* must be an instance of the type. Once an attribute has been set once,
* future attempts will be ignored and false
will be
* returned.
*
* @param type
* The type this attribute is representing.
* @param value
* The value of the object.
* @return true
if the attribute was set successfully.
*/
public boolean setAttribute( Class> type, Object value ) {
String key = type.getName();
Map attributes = ( Map ) getExtra();
if ( attributes == null ) {
attributes = new java.util.HashMap();
setExtra( attributes );
}
else if ( attributes.containsKey( key ) )
return false;
attributes.put( key, value );
return true;
}
public Object getAttribute( Class> type ) {
Map attributes = ( Map ) getExtra();
if ( attributes != null ) {
return attributes.get( type.getName() );
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy