io.deephaven.appmode.StaticClassApplication 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-2024 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 StaticClassApplication implements ApplicationConfig {
public static final String TYPE = "static";
public static StaticClassApplication parse(Properties properties)
throws ClassNotFoundException {
// noinspection unchecked
Class clazz = (Class) Class.forName(properties.getProperty("class"));
return ImmutableStaticClassApplication.of(clazz, ApplicationUtil.isEnabled(properties));
}
public static StaticClassApplication of(Class clazz, boolean isEnabled) {
return ImmutableStaticClassApplication.of(clazz, isEnabled);
}
@Parameter
public abstract Class clazz();
@Parameter
public abstract boolean isEnabled();
public final Application create() throws InstantiationException, IllegalAccessException {
return clazz().newInstance().create();
}
@Override
public final V walk(V visitor) {
visitor.visit(this);
return visitor;
}
@Check
final void checkClazz() {
if (!Application.Factory.class.isAssignableFrom(clazz())) {
throw new IllegalArgumentException(
String.format("clazz should extend '%s'", Application.Factory.class));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy