io.deephaven.appmode.DynamicApplication Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-application-mode Show documentation
Show all versions of deephaven-application-mode Show documentation
The 'application-mode' project
/**
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
*/
package io.deephaven.appmode;
import io.deephaven.annotations.SimpleStyle;
import org.immutables.value.Value.Check;
import org.immutables.value.Value.Immutable;
import org.immutables.value.Value.Parameter;
import java.util.Properties;
@Immutable
@SimpleStyle
public abstract class DynamicApplication implements ApplicationConfig {
public static final String TYPE = "dynamic";
public static DynamicApplication parse(Properties properties)
throws ClassNotFoundException {
// noinspection unchecked
Class clazz =
(Class) Class.forName(properties.getProperty("class"));
return ImmutableDynamicApplication.of(clazz, ApplicationUtil.isEnabled(properties));
}
public static DynamicApplication of(Class clazz, boolean isEnabled) {
return ImmutableDynamicApplication.of(clazz, isEnabled);
}
@Parameter
public abstract Class clazz();
@Parameter
public abstract boolean isEnabled();
public final ApplicationState create(ApplicationState.Listener appStateListener)
throws InstantiationException, IllegalAccessException {
return clazz().newInstance().create(appStateListener);
}
@Override
public final V walk(V visitor) {
visitor.visit(this);
return visitor;
}
@Check
final void checkClazz() {
if (!ApplicationState.Factory.class.isAssignableFrom(clazz())) {
throw new IllegalArgumentException(
String.format("clazz should extend '%s'", ApplicationState.Factory.class));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy