{
ManagedAttribute annotation = m.getAnnotation(ManagedAttribute.class);
if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz))
{
throw new ServerScopedRuntimeException("Can only define ManagedAttributes on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria.");
}
ConfiguredObjectAttribute<?,?> attribute = new ConfiguredAutomatedAttribute<>(clazz, m, annotation);
if(attributeSet.contains(attribute))
{
attributeSet.remove(attribute);
}
attributeSet.add(attribute);
}
else if(m.isAnnotationPresent(DerivedAttribute.class))
{
DerivedAttribute annotation = m.getAnnotation(DerivedAttribute.class);
if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz))
{
throw new ServerScopedRuntimeException("Can only define DerivedAttributes on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria.");
}
ConfiguredObjectAttribute<?,?> attribute = new ConfiguredDerivedAttribute<>(clazz, m, annotation);
if(attributeSet.contains(attribute))
{
attributeSet.remove(attribute);
}
attributeSet.add(attribute);
}
else if(m.isAnnotationPresent(ManagedStatistic.class))
{
ManagedStatistic statAnnotation = m.getAnnotation(ManagedStatistic.class);
if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz))
{
throw new ServerScopedRuntimeException("Can only define ManagedStatistics on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria.");
}
ConfiguredObjectStatistic statistic = new ConfiguredObjectStatistic(clazz, m);
if(statisticSet.contains(statistic))
{
statisticSet.remove(statistic);