io.logspace.jvm.agent.api.order.PropertyType Maven / Gradle / Ivy
The newest version!
/**
* Logspace
* Copyright (c) 2015 Indoqa Software Design und Beratung GmbH. All rights reserved.
* This program and the accompanying materials are made available under the terms of
* the Eclipse Public License Version 1.0, which accompanies this distribution and
* is available at http://www.eclipse.org/legal/epl-v10.html.
*/
package io.logspace.jvm.agent.api.order;
import static io.logspace.jvm.agent.api.order.Aggregate.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Defines the types of the values an {@link io.logspace.jvm.agent.api.event.EventProperty EventProperty} can carry and which aggregations
* are possible for those values.
*/
public enum PropertyType {
BOOLEAN(count), DATE(count, min, max, avg), INTEGER(count, min, max, avg, sum), LONG(count, min, max, avg, sum),
FLOAT(count, min, max, avg, sum), DOUBLE(count, min, max, avg, sum), STRING(count);
private static final Map PROPERTY_TYPES = new HashMap();
static {
for (PropertyType eachValue : PropertyType.values()) {
PROPERTY_TYPES.put(eachValue.name().toLowerCase(), eachValue);
}
}
private final Set allowedAggregates = new HashSet();
private PropertyType(Aggregate... allowedAggregate) {
for (Aggregate eachAllowedAggregate : allowedAggregate) {
this.allowedAggregates.add(eachAllowedAggregate);
}
}
public static PropertyType get(String name) {
if (name == null) {
return null;
}
return PROPERTY_TYPES.get(name.toLowerCase());
}
public Set getAllowedAggregates() {
return this.allowedAggregates;
}
public boolean isAllowed(Aggregate aggregate) {
return this.allowedAggregates.contains(aggregate);
}
}