index int64 0 0 | repo_id stringlengths 26 205 | file_path stringlengths 51 246 | content stringlengths 8 433k | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator/lifecycle/LoggingLifecycleListener.java | package com.netflix.governator.lifecycle;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.TypeLiteral;
public class LoggingLifecycleListener extends DefaultLifecycleListener {
private static final Logger LOG = LoggerFactory.getLogger(LoggingLifecycleListener.class);
@Override
public <T> void objectInjected(TypeLiteral<T> type, T obj) {
LOG.info("Injected {} {}@{}", new Object[]{
type.toString(),
obj.getClass().getName(),
Integer.toHexString(System.identityHashCode(obj))});
}
@Override
public void stateChanged(Object obj, LifecycleState newState) {
}
@Override
public <T> void objectInjected(TypeLiteral<T> type, T obj, long duration, TimeUnit units) {
LOG.info("Injected {} in {} {}", new Object[]{
type.toString(),
TimeUnit.MILLISECONDS.convert(duration, TimeUnit.NANOSECONDS),
TimeUnit.MILLISECONDS});
}
@Override
public <T> void objectInjecting(TypeLiteral<T> type) {
LOG.info("Injecting {}", new Object[]{type.toString()});
}
}
| 5,800 |
0 | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator/lifecycle/ResourceLocator.java | package com.netflix.governator.lifecycle;
import com.netflix.governator.guice.BootstrapBinder;
import javax.annotation.Resource;
import javax.annotation.Resources;
import javax.naming.NameNotFoundException;
/**
* Used to load {@link Resource} and {@link Resources} annotated objects. Bind
* one or more instances via {@link BootstrapBinder#bindResourceLocator()}.
*/
public interface ResourceLocator
{
/**
* Load and return the given resource. If you cannot or do not wish to load
* it, pass on to the next locator in the chain. NOTE: the default ResourceLocator
* merely throws {@link NameNotFoundException}.
*
* @param resource the resource to load - NOTE: type() and name() will have been adjusted if defaults were used.
* @param nextInChain the next locator in the chain (never <code>null</code>)
* @return the loaded object
* @throws Exception errors
*/
public Object locate(Resource resource, ResourceLocator nextInChain) throws Exception;
}
| 5,801 |
0 | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator/lifecycle/ConfigurationProcessor.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.governator.lifecycle;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Date;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.base.Throwables;
import com.netflix.governator.annotations.Configuration;
import com.netflix.governator.configuration.ConfigurationDocumentation;
import com.netflix.governator.configuration.ConfigurationKey;
import com.netflix.governator.configuration.ConfigurationProvider;
import com.netflix.governator.configuration.KeyParser;
import com.netflix.governator.configuration.Property;
class ConfigurationProcessor
{
private final static Logger log = LoggerFactory.getLogger(ConfigurationProcessor.class);
private final ConfigurationProvider configurationProvider;
private final ConfigurationDocumentation configurationDocumentation;
ConfigurationProcessor(ConfigurationProvider configurationProvider, ConfigurationDocumentation configurationDocumentation)
{
this.configurationProvider = configurationProvider;
this.configurationDocumentation = configurationDocumentation;
}
void assignConfiguration(Object obj, Field field, Map<String, String> contextOverrides) throws Exception
{
Configuration configuration = field.getAnnotation(Configuration.class);
String configurationName = configuration.value();
ConfigurationKey key = new ConfigurationKey(configurationName, KeyParser.parse(configurationName, contextOverrides));
Object value = null;
boolean has = configurationProvider.has(key);
if ( has )
{
try
{
if ( Supplier.class.isAssignableFrom(field.getType()) )
{
ParameterizedType type = (ParameterizedType)field.getGenericType();
Type actualType = type.getActualTypeArguments()[0];
Class<?> actualClass;
if (actualType instanceof Class) {
actualClass = (Class<?>) actualType;
} else if (actualType instanceof ParameterizedType) {
actualClass = (Class<?>) ((ParameterizedType) actualType).getRawType();
} else {
throw new UnsupportedOperationException("Supplier parameter type " + actualType
+ " not supported (" + field.getName() + ")");
}
Supplier<?> current = LifecycleMethods.fieldGet(field, obj);
value = getConfigurationSupplier(field, key, actualClass, current);
if ( value == null )
{
log.error("Field type not supported: " + actualClass + " (" + field.getName() + ")");
field = null;
}
}
else if ( Property.class.isAssignableFrom(field.getType()) )
{
ParameterizedType type = (ParameterizedType)field.getGenericType();
Type actualType = type.getActualTypeArguments()[0];
Class<?> actualClass;
if (actualType instanceof Class) {
actualClass = (Class<?>) actualType;
} else if (actualType instanceof ParameterizedType) {
actualClass = (Class<?>) ((ParameterizedType) actualType).getRawType();
} else {
throw new UnsupportedOperationException("Supplier parameter type " + actualType
+ " not supported (" + field.getName() + ")");
}
Property<?> current = LifecycleMethods.fieldGet(field, obj);
value = getConfigurationProperty(field, key, actualClass, current);
if ( value == null )
{
log.error("Field type not supported: " + actualClass + " (" + field.getName() + ")");
field = null;
}
}
else
{
Supplier<?> supplier = getConfigurationSupplier(field, key, field.getType(), Suppliers.ofInstance(LifecycleMethods.fieldGet(field, obj)));
if ( supplier == null )
{
log.error("Field type not supported: " + field.getType() + " (" + field.getName() + ")");
field = null;
}
else
{
value = supplier.get();
}
}
}
catch ( IllegalArgumentException e )
{
ignoreTypeMismtachIfConfigured(configuration, configurationName, e);
field = null;
}
// catch ( ConversionException e )
// {
// ignoreTypeMismtachIfConfigured(configuration, configurationName, e);
// field = null;
// }
}
if ( field != null )
{
String defaultValue;
if ( Supplier.class.isAssignableFrom(field.getType()) )
{
Supplier<?> supplier = LifecycleMethods.fieldGet(field, obj);
defaultValue = String.valueOf(supplier.get());
}
else
{
defaultValue = String.valueOf((Object)LifecycleMethods.fieldGet(field, obj));
}
String documentationValue;
if ( has )
{
LifecycleMethods.fieldSet(field, obj, value);
documentationValue = String.valueOf(value);
if ( Supplier.class.isAssignableFrom(field.getType()) )
{
documentationValue = String.valueOf(((Supplier<?>)value).get());
}
else
{
documentationValue = String.valueOf(documentationValue);
}
}
else
{
documentationValue = "";
}
configurationDocumentation.registerConfiguration(field, configurationName, has, defaultValue, documentationValue, configuration.documentation());
}
}
private Property<?> getConfigurationProperty(Field field, ConfigurationKey key, Class<?> type, Property<?> current) {
return Property.from(getConfigurationSupplier(field, key, type, Property.from(current)));
}
@SuppressWarnings("unchecked")
private Supplier<?> getConfigurationSupplier(final Field field, final ConfigurationKey key, final Class<?> type, Supplier<?> current)
{
if ( String.class.isAssignableFrom(type) )
{
return configurationProvider.getStringSupplier(key, (String)current.get());
}
else if ( Boolean.class.isAssignableFrom(type) || Boolean.TYPE.isAssignableFrom(type) )
{
return configurationProvider.getBooleanSupplier(key, (Boolean)current.get());
}
else if ( Integer.class.isAssignableFrom(type) || Integer.TYPE.isAssignableFrom(type) )
{
return configurationProvider.getIntegerSupplier(key, (Integer)current.get());
}
else if ( Long.class.isAssignableFrom(type) || Long.TYPE.isAssignableFrom(type) )
{
return configurationProvider.getLongSupplier(key, (Long)current.get());
}
else if ( Double.class.isAssignableFrom(type) || Double.TYPE.isAssignableFrom(type) )
{
return configurationProvider.getDoubleSupplier(key, (Double)current.get());
}
else if ( Date.class.isAssignableFrom(type) )
{
return configurationProvider.getDateSupplier(key, (Date)current.get());
}
else
{
/* Try to deserialize */
return configurationProvider.getObjectSupplier(key, current.get(), (Class<Object>) type);
}
}
private void ignoreTypeMismtachIfConfigured(Configuration configuration, String configurationName, Exception e)
{
if ( configuration.ignoreTypeMismatch() )
{
log.info(String.format("Type conversion failed for configuration name %s. This error will be ignored and the field will have the default value if specified. Error: %s", configurationName, e));
}
else
{
throw Throwables.propagate(e);
}
}
}
| 5,802 |
0 | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator/lifecycle/DefaultLifecycleListener.java | package com.netflix.governator.lifecycle;
import java.util.concurrent.TimeUnit;
import com.google.inject.TypeLiteral;
public class DefaultLifecycleListener implements LifecycleListener {
@Override
public <T> void objectInjected(TypeLiteral<T> type, T obj) {
}
public <T> void objectInjected(TypeLiteral<T> type, T obj, long duration, TimeUnit units) {
}
@Override
public void stateChanged(Object obj, LifecycleState newState) {
}
public <T> void objectInjecting(TypeLiteral<T> type) {
}
}
| 5,803 |
0 | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator/lifecycle/AnnotationFinder.java | package com.netflix.governator.lifecycle;
import static org.objectweb.asm.Type.ARRAY;
import static org.objectweb.asm.Type.BOOLEAN;
import static org.objectweb.asm.Type.BYTE;
import static org.objectweb.asm.Type.CHAR;
import static org.objectweb.asm.Type.DOUBLE;
import static org.objectweb.asm.Type.FLOAT;
import static org.objectweb.asm.Type.INT;
import static org.objectweb.asm.Type.LONG;
import static org.objectweb.asm.Type.OBJECT;
import static org.objectweb.asm.Type.SHORT;
import static org.objectweb.asm.Type.getArgumentTypes;
import static org.objectweb.asm.Type.getType;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class AnnotationFinder extends ClassVisitor {
private static Logger log = LoggerFactory.getLogger(AnnotationFinder.class);
private Set<Type> annotationTypes;
private Set<Class<?>> annotatedClasses = Collections.emptySet();
private Set<Method> annotatedMethods = new HashSet<>();
private Set<Constructor> annotatedConstructors = new HashSet<>();
private Set<Field> annotatedFields = new HashSet<>();
private String className;
private Class<?> clazz;
private ClassLoader classLoader;
private Class<?> selfClass() {
if (clazz == null)
clazz = classFromInternalName(className);
return clazz;
}
private Class<?> classFromInternalName(String name) {
try {
return Class.forName(name.replace('/', '.'), false, classLoader);
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Unable to find class " + name, e);
}
}
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
className = name;
super.visit(version, access, name, signature, superName, interfaces);
}
public AnnotationFinder(ClassLoader classLoader, Collection<Class<? extends Annotation>> annotations) {
super(Opcodes.ASM7);
annotationTypes = new HashSet<>();
for (Class<?> annotation : annotations)
annotationTypes.add(getType(annotation));
this.classLoader = classLoader;
}
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
Type type = getType(desc);
for (Type annotationType : annotationTypes) {
if (annotationType.equals(type)) {
annotatedClasses = Collections.<Class<?>>singleton(selfClass());
break;
}
}
return super.visitAnnotation(desc, visible);
}
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
return new AnnotationSeekingFieldVisitor(name, super.visitField(access, name, desc, signature, value));
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
return new AnnotationSeekingMethodVisitor(super.visitMethod(access, name, desc, signature, exceptions), name, desc);
}
private class AnnotationSeekingFieldVisitor extends FieldVisitor {
String name;
public AnnotationSeekingFieldVisitor(String name, FieldVisitor fv) {
super(Opcodes.ASM7, fv);
this.name = name;
}
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
Type type = getType(desc);
for (Type annotationType : annotationTypes) {
if (annotationType.equals(type)) {
try {
annotatedFields.add(selfClass().getDeclaredField(name));
break;
} catch (NoSuchFieldException e) {
throw new IllegalStateException("Error visiting field " + name + " of class " + selfClass().getName(), e);
} catch (NoClassDefFoundError e) {
log.info("Unable to scan field '{}' of class '{}'", name, selfClass().getName(), e.getMessage());
}
}
}
return super.visitAnnotation(desc, visible);
}
}
private class AnnotationSeekingMethodVisitor extends MethodVisitor {
String name;
String methodDesc;
public AnnotationSeekingMethodVisitor(MethodVisitor mv, String name, String desc) {
super(Opcodes.ASM7, mv);
this.name = name;
this.methodDesc = desc;
}
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
Type type = getType(desc);
for (Type annotationType : annotationTypes) {
if (annotationType.equals(type)) {
Type[] args = methodDesc == null
? new Type[0]
: getArgumentTypes(methodDesc);
Class[] argClasses = new Class[args.length];
for (int i = 0; i < args.length; i++) {
switch (args[i].getSort()) {
case OBJECT:
case ARRAY:
argClasses[i] = classFromInternalName(args[i].getInternalName());
break;
case BOOLEAN:
argClasses[i] = boolean.class;
break;
case BYTE:
argClasses[i] = byte.class;
break;
case CHAR:
argClasses[i] = char.class;
break;
case DOUBLE:
argClasses[i] = double.class;
break;
case FLOAT:
argClasses[i] = float.class;
break;
case INT:
argClasses[i] = int.class;
break;
case LONG:
argClasses[i] = long.class;
break;
case SHORT:
argClasses[i] = short.class;
break;
}
}
try {
if ("<init>".equals(name))
annotatedConstructors.add(selfClass()
.getDeclaredConstructor(argClasses));
else
annotatedMethods.add(selfClass().getDeclaredMethod(
name, argClasses));
} catch (NoClassDefFoundError e) {
log.info("Unable to scan constructor of '{}' NoClassDefFoundError looking for '{}'", selfClass().getName(), e.getMessage());
} catch (NoSuchMethodException e) {
throw new IllegalStateException(e);
}
break;
}
}
return super.visitAnnotation(desc, visible);
}
}
/**
* @return a 0 or 1 element Set, depending on whether the class being
* visited has a matching class annotation
*/
public Set<Class<?>> getAnnotatedClasses() {
return annotatedClasses;
}
public Set<Method> getAnnotatedMethods() {
return annotatedMethods;
}
public Set<Constructor> getAnnotatedConstructors() {
return annotatedConstructors;
}
public Set<Field> getAnnotatedFields() {
return annotatedFields;
}
}
| 5,804 |
0 | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator | Create_ds/governator/governator-legacy/src/main/java/com/netflix/governator/annotations/Modules.java | package com.netflix.governator.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.google.inject.Module;
import com.netflix.governator.guice.annotations.Bootstrap;
import com.netflix.governator.guice.bootstrap.ModulesBootstrap;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Bootstrap(bootstrap=ModulesBootstrap.class)
@Deprecated
/**
* @deprecated Use Guice's built in module deduping using hashCode and equals instead
* http://www.mattinsler.com/post/26548709502/google-guice-module-de-duplication
*/
public @interface Modules {
/**
* Modules to include
*/
Class<? extends Module>[] include() default {};
/**
* Modules to exclude
*/
Class<? extends Module>[] exclude() default {};
/**
* Modules to force include if there is an exclude
*/
Class<? extends Module>[] force() default {};
}
| 5,805 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/configuration/ExampleObject.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package configuration;
import com.netflix.governator.annotations.Configuration;
import com.netflix.governator.annotations.PreConfiguration;
public class ExampleObject
{
@Configuration("${prefix}.a-string")
private String aString = "default value";
@Configuration("${prefix}.an-int")
private int anInt = 0;
@Configuration("${prefix}.a-double")
private double aDouble = 0;
@PreConfiguration
public void preConfig()
{
System.out.println("preConfig");
}
public String getAString()
{
return aString;
}
public int getAnInt()
{
return anInt;
}
public double getADouble()
{
return aDouble;
}
public void setAString(String aString)
{
this.aString = aString;
}
public void setAnInt(int anInt)
{
this.anInt = anInt;
}
public void setADouble(double aDouble)
{
this.aDouble = aDouble;
}
}
| 5,806 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/configuration/ConfigurationExample.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package configuration;
import com.google.inject.Injector;
import com.netflix.governator.configuration.SystemConfigurationProvider;
import com.netflix.governator.guice.BootstrapBinder;
import com.netflix.governator.guice.BootstrapModule;
import com.netflix.governator.guice.LifecycleInjector;
import com.netflix.governator.lifecycle.LifecycleManager;
public class ConfigurationExample
{
public static void main(String[] args) throws Exception
{
// in this example we'll use system properties
// with a variable "prefix" to select the property
System.setProperty("first.a-string", "first string");
System.setProperty("first.an-int", "1");
System.setProperty("first.a-double", "1.1");
System.setProperty("second.a-string", "second string");
System.setProperty("second.an-int", "2");
System.setProperty("second.a-double", "2.2");
// execute the example twice. The first time with the prefix
// set to "first". The second time with it set to "second"
SystemConfigurationProvider provider = new SystemConfigurationProvider();
provider.setVariable("prefix", "first");
doWork(provider);
provider.setVariable("prefix", "second");
doWork(provider);
/*
Console will show:
preConfig
first string
1
1.1
preConfig
second string
2
2.2
*/
}
private static void doWork(final SystemConfigurationProvider provider) throws Exception
{
// Always get the Guice injector from Governator
Injector injector = LifecycleInjector
.builder()
.withBootstrapModule
(
new BootstrapModule()
{
@Override
public void configure(BootstrapBinder binder)
{
// bind the configuration provider
binder.bindConfigurationProvider().toInstance(provider);
}
}
)
.createInjector();
ExampleObject obj = injector.getInstance(ExampleObject.class);
LifecycleManager manager = injector.getInstance(LifecycleManager.class);
// Always start the Lifecycle Manager
manager.start();
System.out.println(obj.getAString());
System.out.println(obj.getAnInt());
System.out.println(obj.getADouble());
// your app would execute here
// Always close the Lifecycle Manager at app end
manager.close();
}
}
| 5,807 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/custom_autobind/CustomAutoBindExample.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package custom_autobind;
import com.google.inject.Injector;
import com.google.inject.TypeLiteral;
import com.netflix.governator.guice.AutoBindProvider;
import com.netflix.governator.guice.BootstrapBinder;
import com.netflix.governator.guice.BootstrapModule;
import com.netflix.governator.guice.LifecycleInjector;
import com.netflix.governator.lifecycle.LifecycleManager;
public class CustomAutoBindExample
{
public static void main(String[] args) throws Exception
{
System.setProperty("prop-a", "ExampleObjectA should see this");
// Always get the Guice injector from Governator
Injector injector = LifecycleInjector
.builder()
.usingBasePackages("custom_autobind")
.withBootstrapModule
(
new BootstrapModule()
{
@Override
public void configure(BootstrapBinder binder)
{
// bind an AutoBindProvider for @ExampleAutoBind annotated fields/arguments
TypeLiteral<AutoBindProvider<ExampleAutoBind>> typeLiteral = new TypeLiteral<AutoBindProvider<ExampleAutoBind>>(){};
binder.bind(typeLiteral).to(ExampleAutoBindProvider.class).asEagerSingleton();
}
}
)
.createInjector();
LifecycleManager manager = injector.getInstance(LifecycleManager.class);
// Always start the Lifecycle Manager
manager.start();
System.out.println(injector.getInstance(ExampleObjectA.class).getValue());
System.out.println(injector.getInstance(ExampleObjectB.class).getValue());
System.out.println(injector.getInstance(ExampleObjectC.class).getValue());
/*
Console will output:
ExampleObjectA should see this
b
c
*/
// your app would execute here
// Always close the Lifecycle Manager at app end
manager.close();
}
}
| 5,808 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/custom_autobind/ExampleAutoBind.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package custom_autobind;
import com.google.inject.BindingAnnotation;
import com.netflix.governator.annotations.AutoBind;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.PARAMETER})
@BindingAnnotation
@AutoBind
public @interface ExampleAutoBind
{
String propertyName();
String defaultValue();
}
| 5,809 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/custom_autobind/ExampleObjectC.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package custom_autobind;
import com.google.inject.Inject;
import com.netflix.governator.annotations.AutoBind;
public class ExampleObjectC
{
private final String value;
@Inject
public ExampleObjectC(@ExampleAutoBind(propertyName = "prop-c", defaultValue = "c") String value)
{
this.value = value;
}
public String getValue()
{
return value;
}
}
| 5,810 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/custom_autobind/ExampleObjectB.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package custom_autobind;
import com.google.inject.Inject;
import com.netflix.governator.annotations.AutoBind;
public class ExampleObjectB
{
private final String value;
@Inject
public ExampleObjectB(@ExampleAutoBind(propertyName = "prop-b", defaultValue = "b") String value)
{
this.value = value;
}
public String getValue()
{
return value;
}
}
| 5,811 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/custom_autobind/ExampleObjectA.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package custom_autobind;
import com.google.inject.Inject;
import com.netflix.governator.annotations.AutoBind;
public class ExampleObjectA
{
private final String value;
@Inject
public ExampleObjectA(@ExampleAutoBind(propertyName = "prop-a", defaultValue = "a") String value)
{
this.value = value;
}
public String getValue()
{
return value;
}
}
| 5,812 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/custom_autobind/ExampleAutoBindProvider.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package custom_autobind;
import com.google.inject.Binder;
import com.netflix.governator.guice.AutoBindProvider;
public class ExampleAutoBindProvider implements AutoBindProvider<ExampleAutoBind>
{
@Override
public void configure(Binder binder, ExampleAutoBind annotation)
{
String value = System.getProperty(annotation.propertyName(), annotation.defaultValue());
binder.bind(String.class).annotatedWith(annotation).toInstance(value);
}
}
| 5,813 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/lifecycle/ExampleService.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package lifecycle;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@Singleton
public class ExampleService
{
@Inject
public ExampleService(ExampleResource resource)
{
System.out.println("ExampleService construction");
}
@PostConstruct
public void setup()
{
System.out.println("ExampleService setup");
}
@PreDestroy
public void tearDown()
{
System.out.println("ExampleService tearDown");
}
}
| 5,814 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/lifecycle/ExampleResource.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package lifecycle;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@Singleton
public class ExampleResource
{
@Inject
public ExampleResource()
{
System.out.println("ExampleResource construction");
}
@PostConstruct
public void setup()
{
System.out.println("ExampleResource setup");
}
@PreDestroy
public void tearDown()
{
System.out.println("ExampleResource tearDown");
}
}
| 5,815 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/lifecycle/LifecycleExample.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package lifecycle;
import com.google.inject.Injector;
import com.netflix.governator.guice.LifecycleInjector;
import com.netflix.governator.lifecycle.LifecycleManager;
public class LifecycleExample
{
public static void main(String[] args) throws Exception
{
// Always get the Guice injector from Governator
Injector injector = LifecycleInjector.builder().createInjector();
// This causes ExampleService and its dependency, ExampleResource, to get instantiated
injector.getInstance(ExampleService.class);
LifecycleManager manager = injector.getInstance(LifecycleManager.class);
// Always start the Lifecycle Manager
manager.start();
// your app would execute here
// Always close the Lifecycle Manager at app end
manager.close();
/*
The console output should show:
ExampleResource construction
ExampleResource setup
ExampleService construction
ExampleService setup
ExampleService tearDown
ExampleResource tearDown
*/
}
}
| 5,816 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/autobind/AutoBindSingletonExample.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package autobind;
import com.google.inject.Injector;
import com.netflix.governator.guice.LifecycleInjector;
import com.netflix.governator.lifecycle.LifecycleManager;
public class AutoBindSingletonExample
{
public static void main(String[] args) throws Exception
{
// Always get the Guice injector from Governator
Injector injector = LifecycleInjector
.builder()
.usingBasePackages("autobind") // specify a package for CLASSPATH scanning so that Governator finds the AutoBindSingleton
.createInjector();
// NOTE: ExampleService will be created at this point - you should see "ExampleService auto-bind construction" in the console
LifecycleManager manager = injector.getInstance(LifecycleManager.class);
// Always start the Lifecycle Manager
manager.start();
// your app would execute here
// Always close the Lifecycle Manager at app end
manager.close();
}
}
| 5,817 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/autobind/ExampleObjectC.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package autobind;
import com.google.inject.Inject;
import com.netflix.governator.annotations.AutoBind;
public class ExampleObjectC
{
private final String value;
@Inject
public ExampleObjectC(@AutoBind("letter C") String value)
{
this.value = value;
}
public String getValue()
{
return value;
}
}
| 5,818 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/autobind/ExampleService.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package autobind;
import com.google.inject.Inject;
import com.netflix.governator.annotations.AutoBindSingleton;
@AutoBindSingleton
public class ExampleService
{
@Inject
public ExampleService()
{
System.out.println("ExampleService auto-bind construction");
}
}
| 5,819 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/autobind/ExampleObjectB.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package autobind;
import com.google.inject.Inject;
import com.netflix.governator.annotations.AutoBind;
public class ExampleObjectB
{
private final String value;
@Inject
public ExampleObjectB(@AutoBind("letter B") String value)
{
this.value = value;
}
public String getValue()
{
return value;
}
}
| 5,820 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/autobind/ExampleObjectA.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package autobind;
import com.google.inject.Inject;
import com.netflix.governator.annotations.AutoBind;
public class ExampleObjectA
{
private final String value;
@Inject
public ExampleObjectA(@AutoBind("letter A")String value)
{
this.value = value;
}
public String getValue()
{
return value;
}
}
| 5,821 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/autobind/ExampleAutoBindProvider.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package autobind;
import com.google.inject.Binder;
import com.netflix.governator.annotations.AutoBind;
import com.netflix.governator.guice.AutoBindProvider;
import java.util.concurrent.atomic.AtomicInteger;
public class ExampleAutoBindProvider implements AutoBindProvider<AutoBind>
{
private final AtomicInteger counter = new AtomicInteger();
@Override
public void configure(Binder binder, AutoBind annotation)
{
// this method will get called for each field/argument that is annotated
// with @AutoBind. NOTE: the fields/methods/constructors must also
// be annotated with @Inject
String value = annotation.value() + " - " + counter.incrementAndGet();
binder.bind(String.class).annotatedWith(annotation).toInstance(value);
}
}
| 5,822 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/autobind/AutoBindExample.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package autobind;
import com.google.common.collect.Lists;
import com.google.inject.Injector;
import com.google.inject.TypeLiteral;
import com.netflix.governator.annotations.AutoBind;
import com.netflix.governator.guice.AutoBindProvider;
import com.netflix.governator.guice.BootstrapBinder;
import com.netflix.governator.guice.BootstrapModule;
import com.netflix.governator.guice.LifecycleInjector;
import com.netflix.governator.lifecycle.LifecycleManager;
import java.util.List;
public class AutoBindExample
{
public static void main(String[] args) throws Exception
{
// This Governator feature tells the CLASSPATH scanner
// to ignore listed classes. So, even though ExampleService
// is annotated with @AutoBindSingleton it will not
// get created in this example
List<Class<?>> ignore = Lists.newArrayList();
ignore.add(ExampleService.class);
// Always get the Guice injector from Governator
Injector injector = LifecycleInjector
.builder()
.usingBasePackages("autobind")
.ignoringAutoBindClasses(ignore) // tell Governator's CLASSPATH scanner to ignore listed classes
.withBootstrapModule
(
new BootstrapModule()
{
@Override
public void configure(BootstrapBinder binder)
{
// bind an AutoBindProvider for @AutoBind annotated fields/arguments
TypeLiteral<AutoBindProvider<AutoBind>> typeLiteral = new TypeLiteral<AutoBindProvider<AutoBind>>(){};
binder.bind(typeLiteral).to(ExampleAutoBindProvider.class).asEagerSingleton();
}
}
)
.createInjector();
LifecycleManager manager = injector.getInstance(LifecycleManager.class);
// Always start the Lifecycle Manager
manager.start();
System.out.println(injector.getInstance(ExampleObjectA.class).getValue());
System.out.println(injector.getInstance(ExampleObjectB.class).getValue());
System.out.println(injector.getInstance(ExampleObjectC.class).getValue());
/*
Console will output:
letter A - 1
letter B - 2
letter C - 3
*/
// your app would execute here
// Always close the Lifecycle Manager at app end
manager.close();
}
}
| 5,823 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/warmup/ExampleObjectC.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package warmup;
import com.netflix.governator.annotations.WarmUp;
import java.util.concurrent.atomic.AtomicBoolean;
public class ExampleObjectC
{
private final AtomicBoolean isWarm = new AtomicBoolean(false);
@WarmUp
public void warmUp() throws InterruptedException
{
System.out.println("ExampleObjectC warm up start");
Thread.sleep(1000);
System.out.println("ExampleObjectC warm up end");
isWarm.set(true);
}
public boolean isWarm()
{
return isWarm.get();
}
}
| 5,824 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/warmup/ExampleObjectB.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package warmup;
import com.netflix.governator.annotations.WarmUp;
import java.util.concurrent.atomic.AtomicBoolean;
public class ExampleObjectB
{
private final AtomicBoolean isWarm = new AtomicBoolean(false);
@WarmUp
public void warmUp() throws InterruptedException
{
System.out.println("ExampleObjectB warm up start");
Thread.sleep(1000);
System.out.println("ExampleObjectB warm up end");
isWarm.set(true);
}
public boolean isWarm()
{
return isWarm.get();
}
}
| 5,825 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/warmup/ExampleObjectA.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package warmup;
import com.google.inject.Inject;
import com.netflix.governator.annotations.AutoBindSingleton;
import com.netflix.governator.annotations.WarmUp;
@AutoBindSingleton
public class ExampleObjectA
{
private final ExampleObjectB b;
private final ExampleObjectC c;
@Inject
public ExampleObjectA(ExampleObjectB b, ExampleObjectC c)
{
this.b = b;
this.c = c;
System.out.println("b.isWarm() " + b.isWarm());
System.out.println("c.isWarm() " + c.isWarm());
}
@WarmUp
public void warmUp() throws InterruptedException
{
System.out.println("b.isWarm() " + b.isWarm());
System.out.println("c.isWarm() " + c.isWarm());
System.out.println("ExampleObjectA warm up start");
Thread.sleep(1000);
System.out.println("ExampleObjectA warm up end");
}
}
| 5,826 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/warmup/WarmUpExample.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package warmup;
import com.google.inject.Injector;
import com.netflix.governator.guice.LifecycleInjector;
import com.netflix.governator.lifecycle.LifecycleManager;
public class WarmUpExample
{
public static void main(String[] args) throws Exception
{
// Always get the Guice injector from Governator
Injector injector = LifecycleInjector.builder().createInjector();
injector.getInstance(ExampleObjectA.class);
LifecycleManager manager = injector.getInstance(LifecycleManager.class);
// Always start the Lifecycle Manager
manager.start();
// by calling start() warm up begins. The console will show
// something like this (the order may be slightly different):
/*
b.isWarm() false
c.isWarm() false
ExampleObjectB warm up start
ExampleObjectC warm up start
ExampleObjectB warm up end
ExampleObjectC warm up end
b.isWarm() true
c.isWarm() true
ExampleObjectA warm up start
ExampleObjectA warm up end
*/
// your app would execute here
// Always close the Lifecycle Manager at app end
manager.close();
}
}
| 5,827 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/validation/ValidationExample.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package validation;
import com.google.inject.Injector;
import com.netflix.governator.configuration.SystemConfigurationProvider;
import com.netflix.governator.guice.BootstrapBinder;
import com.netflix.governator.guice.BootstrapModule;
import com.netflix.governator.guice.LifecycleInjector;
import com.netflix.governator.lifecycle.LifecycleManager;
import com.netflix.governator.lifecycle.ValidationException;
public class ValidationExample
{
public static void main(String[] args) throws Exception
{
// this example combines a number of Governator features.
// It shows validation, AutoBindSingleton and @Configuration
try
{
// There are no properties set which will cause
// the fields of ExampleObject to stay at their defaults.
// Their defaults violate their constraint annotations
// thus an exception will be thrown
doWork();
}
catch ( ValidationException e )
{
// correct
}
// set the annotation properties so that the constraints are not violated
System.setProperty("value", "8");
System.setProperty("str", "a string");
doWork();
}
private static void doWork() throws Exception
{
// Always get the Guice injector from Governator
Injector injector = LifecycleInjector
.builder()
.usingBasePackages("validation")
.withBootstrapModule
(
new BootstrapModule()
{
@Override
public void configure(BootstrapBinder binder)
{
binder.bindConfigurationProvider().to(SystemConfigurationProvider.class);
}
}
)
.createInjector();
LifecycleManager manager = injector.getInstance(LifecycleManager.class);
// Always start the Lifecycle Manager
manager.start();
// your app would execute here
// Always close the Lifecycle Manager at app end
manager.close();
}
}
| 5,828 |
0 | Create_ds/governator/governator-legacy/src/main/examples | Create_ds/governator/governator-legacy/src/main/examples/validation/ExampleObject.java | /*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package validation;
import com.netflix.governator.annotations.AutoBindSingleton;
import com.netflix.governator.annotations.Configuration;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
@AutoBindSingleton
public class ExampleObject
{
@Min(5)
@Max(10)
@Configuration("value")
private int value = 0;
@NotNull
@Configuration("str")
private String str;
public int getValue()
{
return value;
}
public void setValue(int value)
{
this.value = value;
}
public String getStr()
{
return str;
}
public void setStr(String str)
{
this.str = str;
}
}
| 5,829 |
0 | Create_ds/aws-sam-build-images/tests/apps/java17/sam-test-app/HelloWorldFunction/src/main/java | Create_ds/aws-sam-build-images/tests/apps/java17/sam-test-app/HelloWorldFunction/src/main/java/helloworld/App.java | package helloworld;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
/**
* Handler for requests to Lambda function.
*/
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("X-Custom-Header", "application/json");
APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent()
.withHeaders(headers);
try {
String output = String.format("{ \"message\": \"hello world\"}");
return response
.withStatusCode(200)
.withBody(output);
} catch (IOException e) {
return response
.withBody("{}")
.withStatusCode(500);
}
}
private String getPageContents(String address) throws IOException{
URL url = new URL(address);
try(BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) {
return br.lines().collect(Collectors.joining(System.lineSeparator()));
}
}
}
| 5,830 |
0 | Create_ds/aws-sam-build-images/tests/apps/java8/sam-test-app/HelloWorldFunction/src/main/java | Create_ds/aws-sam-build-images/tests/apps/java8/sam-test-app/HelloWorldFunction/src/main/java/helloworld/App.java | package helloworld;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
/**
* Handler for requests to Lambda function.
*/
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("X-Custom-Header", "application/json");
APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent()
.withHeaders(headers);
try {
String output = String.format("{ \"message\": \"hello world\"}");
return response
.withStatusCode(200)
.withBody(output);
} catch (IOException e) {
return response
.withBody("{}")
.withStatusCode(500);
}
}
}
| 5,831 |
0 | Create_ds/aws-sam-build-images/tests/apps/java11/sam-test-app/HelloWorldFunction/src/main/java | Create_ds/aws-sam-build-images/tests/apps/java11/sam-test-app/HelloWorldFunction/src/main/java/helloworld/App.java | package helloworld;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
/**
* Handler for requests to Lambda function.
*/
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("X-Custom-Header", "application/json");
APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent()
.withHeaders(headers);
try {
String output = String.format("{ \"message\": \"hello world\"}");
return response
.withStatusCode(200)
.withBody(output);
} catch (IOException e) {
return response
.withBody("{}")
.withStatusCode(500);
}
}
private String getPageContents(String address) throws IOException{
URL url = new URL(address);
try(BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) {
return br.lines().collect(Collectors.joining(System.lineSeparator()));
}
}
}
| 5,832 |
0 | Create_ds/aws-sam-build-images/tests/apps/java8.al2/sam-test-app/HelloWorldFunction/src/main/java | Create_ds/aws-sam-build-images/tests/apps/java8.al2/sam-test-app/HelloWorldFunction/src/main/java/helloworld/App.java | package helloworld;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
/**
* Handler for requests to Lambda function.
*/
public class App implements RequestHandler<Object, Object> {
public Object handleRequest(final Object input, final Context context) {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("X-Custom-Header", "application/json");
try {
String output = String.format("{ \"message\": \"hello world\"}");
return new GatewayResponse(output, headers, 200);
} catch (IOException e) {
return new GatewayResponse("{}", headers, 500);
}
}
private String getPageContents(String address) throws IOException{
URL url = new URL(address);
try(BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) {
return br.lines().collect(Collectors.joining(System.lineSeparator()));
}
}
}
| 5,833 |
0 | Create_ds/aws-sam-build-images/tests/apps/java8.al2/sam-test-app/HelloWorldFunction/src/main/java | Create_ds/aws-sam-build-images/tests/apps/java8.al2/sam-test-app/HelloWorldFunction/src/main/java/helloworld/GatewayResponse.java | package helloworld;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* POJO containing response object for API Gateway.
*/
public class GatewayResponse {
private final String body;
private final Map<String, String> headers;
private final int statusCode;
public GatewayResponse(final String body, final Map<String, String> headers, final int statusCode) {
this.statusCode = statusCode;
this.body = body;
this.headers = Collections.unmodifiableMap(new HashMap<>(headers));
}
public String getBody() {
return body;
}
public Map<String, String> getHeaders() {
return headers;
}
public int getStatusCode() {
return statusCode;
}
}
| 5,834 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/function_call.java | callSomeFunction(1, 2, 3);
| 5,835 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/shorthand_property.java | String foo = "hello";
callFunction(Map.of("foo", foo));
| 5,836 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/default_struct_fields.java | public class Struct {
private String x;
public String getX() {
return this.x;
}
public Struct x(String x) {
this.x = x;
return this;
}
private String y;
public String getY() {
return this.y;
}
public Struct y(String y) {
this.y = y;
return this;
}
}
public void foo(Struct s) {
System.out.println(s.getX() + s.getY());
}
| 5,837 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/translate_object_literals_second_level_with_newlines.java | foo(25, Map.of("foo", 3, "deeper", Map.of(
"a", 1,
"b", 2)));
| 5,838 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/translate_object_literals_with_multiple_newlines.java | foo(25, Map.of(
"foo", 3,
"banana", "hello"));
| 5,839 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/method_call.java | someObject.callSomeFunction(1, 2, 3);
| 5,840 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/list_of_anonymous_structs.java | foo(Map.of(
"list", List.of(Map.of(
"a", 1,
"b", 2), Map.of(
"a", 3,
"b", 4))));
| 5,841 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/declaring_default_arguments.java | public void foo(String x) {
foo(x, "hello");
}
public void foo(String x, String y) {
foo(x, y, null);
}
public void foo(String x, String y, String z) {
System.out.println(x + y + z);
}
| 5,842 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/will_type_deep_structs_directly_if_type_info_is_available.java | public class BaseDeeperStruct {
private Number a;
public Number getA() {
return this.a;
}
public BaseDeeperStruct a(Number a) {
this.a = a;
return this;
}
}
public class DeeperStruct extends BaseDeeperStruct {
private Number b;
public Number getB() {
return this.b;
}
public DeeperStruct b(Number b) {
this.b = b;
return this;
}
}
public class OuterStruct {
private Number foo;
public Number getFoo() {
return this.foo;
}
public OuterStruct foo(Number foo) {
this.foo = foo;
return this;
}
private DeeperStruct deeper;
public DeeperStruct getDeeper() {
return this.deeper;
}
public OuterStruct deeper(DeeperStruct deeper) {
this.deeper = deeper;
return this;
}
}
public void foo(Number x, OuterStruct outer) {
}
foo(25, OuterStruct.builder().foo(3).deeper(DeeperStruct.builder()
.a(1)
.b(2)
.build()).build());
| 5,843 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/translate_object_literals_in_function_call.java | foo(25, Map.of("foo", 3, "banana", "hello"));
| 5,844 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/static_function_call.java | SomeObject.callSomeFunction(1, 2, 3);
| 5,845 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/literal_map_argument.java | public void foo(Map<String, String> xs) {
}
foo(Map.of("foo", "bar", "schmoo", "schmar"));
| 5,846 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/translate_object_literals_only_one_level_deep.java | foo(25, Map.of("foo", 3, "deeper", Map.of("a", 1, "b", 2)));
| 5,847 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/translate_object_literals_with_newlines.java | foo(25, Map.of(
"foo", 3,
"banana", "hello"));
| 5,848 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/self_method_call.java | this.callSomeFunction(25);
| 5,849 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/calls/this_argument.java | callSomeFunction(this, 25);
| 5,850 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/misc/booleans_render_to_right_primitives.java | callFunction(true, false);
| 5,851 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/comments/no_duplication_of_comments.java | // Here's a comment
object.member.functionCall(new Class(), "argument");
| 5,852 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/comments/empty_lines_in_comments.java | // Here's a comment
//
// Second line
someCall();
| 5,853 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/comments/interleave_multiline_comments_with_function_call.java | someFunction(arg1, Map.of(
/* A comment before arg2 */
"arg2", "string",
/* A comment before arg3 */
"arg3", "boo"));
| 5,854 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/comments/interleave_single_line_comments_with_function_call.java | someFunction(arg1, Map.of(
// A comment before arg2
"arg2", "string",
// A comment before arg3
"arg3", "boo"));
| 5,855 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/invisible_interfaces_do_not_affect_whitespace.java | public class MyClass1 {
}
public class ThisWillNotBeRendered {
}
public class MyClass2 {
}
| 5,856 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/class_with_different_name.java | public class OtherName {
public OtherName() {
}
} | 5,857 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/whitespace_between_multiple_members.java | public class MyClass {
public MyClass(String y) {
this.x = y;
}
public void hello() {
System.out.println(this.x);
}
public void bye() {
System.out.println("bye");
}
}
| 5,858 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/whitespace_between_multiple_empty_members.java | public class MyClass {
public MyClass(String y) {
this.x = y;
}
public void hello() {
}
public void bye() {
}
}
| 5,859 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/class_declaration_with_private_fields_and_constructor.java | public class MyClass {
private final String x;
public MyClass(String y) {
this.x = y;
}
}
| 5,860 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/constructor_with_optional_params.java | public class A {
public A() {
this(null);
}
public A(String a) {
this(a, 3);
}
public A(String a, Number b) {
}
}
| 5,861 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/class_with_method.java | public class MyClass extends SomeOtherClass {
public void someMethod(String x) {
System.out.println(x);
}
}
| 5,862 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/class_with_extends_and_implements.java | public class MyClass extends SomeOtherClass implements SomeInterface {
}
| 5,863 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/empty_class.java | public class empty_class {
}
| 5,864 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/class_declaration_with_public_fields_and_constructor.java | public class MyClass {
public final String x;
public MyClass(String y) {
this.x = y;
}
}
| 5,865 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/class_with_inheritance.java | public class MyClass extends SomeOtherClass {
}
| 5,866 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.java | public class MyClass implements IResolvable {
public Object resolve() {
return 42;
}
} | 5,867 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/class_with_inheritance_and_super_class.java | public class MyClass extends SomeOtherClass {
public MyClass(String x, String y) {
super(x);
}
}
| 5,868 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/classes/class_with_props_argument.java | public class MyClassProps {
private String prop1;
public String getProp1() {
return this.prop1;
}
public MyClassProps prop1(String prop1) {
this.prop1 = prop1;
return this;
}
private Number prop2;
public Number getProp2() {
return this.prop2;
}
public MyClassProps prop2(Number prop2) {
this.prop2 = prop2;
return this;
}
}
public class MyClass extends SomeOtherClass {
public MyClass(Construct scope, String id, MyClassProps props) {
super(scope, id, props);
System.out.println(props.getProp1());
}
}
| 5,869 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/imports/selective_import.java | import scope.some.module.one.*;
import scope.some.module.Two;
import scope.some.module.someThree.*;
import scope.some.module.four.*;
new Two();
renamed();
| 5,870 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/imports/multiple-imports.java | import aws.cdk.lib.*;
import constructs.Construct;
import constructs.IConstruct;
| 5,871 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/imports/submodule-import.java | import software.amazon.jsii.tests.calculator.submodule.*;
import software.amazon.jsii.tests.calculator.submodule.child.*;
import software.amazon.jsii.tests.calculator.homonymousForwardReferences.*;
import software.amazon.jsii.tests.calculator.homonymousForwardReferences.foo.*;
import gen.providers.aws.kms.*;
// Access without existing type information
Object awsKmsKeyExamplekms = KmsKey.Builder.create(this, "examplekms")
.deletionWindowInDays(7)
.description("KMS key 1")
.build();
// Accesses two distinct points of the submodule hierarchy
MyClass myClass = MyClass.Builder.create().prop(SomeEnum.SOME).build();
// Access via a renamed import
Consumer.consume(ConsumerProps.builder().homonymous(Homonymous.builder().stringProperty("yes").build()).build());
| 5,872 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/imports/import_require.java | import scope.some.module.*;
new ClassFromModule();
| 5,873 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/imports/import_star_as.java | import scope.some.module.*;
new ClassFromModule();
| 5,874 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/identifiers/keyword.java | import scope.aws.lambda.*;
ClassFromLambda.Builder.create()
.key("lambda.amazonaws.com")
.build(); | 5,875 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/whitespace_between_statements.java | statementOne();
statementTwo();
| 5,876 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/declare_var.java | Type variable; | 5,877 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/initialize_object_literal.java | Map<String, Object> expected = Map.of(
"Foo", "Bar",
"Baz", 5,
"Qux", List.of("Waldo", "Fred")); | 5,878 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/block_without_braces.java | if (x == 3) System.out.println("hello");
| 5,879 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/statements_and_newlines.java | public Number doThing() {
Number x = 1; // x seems to be equal to 1
return x + 1;
}
public boolean doThing2(Number x) {
if (x == 1) {
return true;
}
return false;
}
public Number doThing3() {
Number x = 1;
return x + 1;
}
public void doThing4() {
Number x = 1;
x = 85;
} | 5,880 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/vararg_any_call.java | public void test(Object... _args) {
}
test(Map.of("Key", "Value", "also", 1337));
test(Map.of("Key", "Value"), Map.of("also", 1337));
| 5,881 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/for_of_loop.java | for (Object x : xs) {
System.out.println(x);
}
| 5,882 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/whitespace_between_statements_in_a_block.java | if (condition) {
statementOne();
statementTwo();
}
| 5,883 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/if_then_else.java | if (x == 3) {
System.out.println("bye");
} else {
System.out.println("toodels");
}
| 5,884 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/if.java | if (x == 3) {
System.out.println("bye");
}
| 5,885 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/empty_control_block.java | if (x == 3) {
}
| 5,886 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/statements/multiline_if_then_else.java | if (x == 3) {
x += 1;
System.out.println("bye");
} else {
System.out.println("toodels");
}
| 5,887 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/hiding/hide_top_level_statements_using_void_directive.java | foo(3);
| 5,888 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/hiding/hide_block_level_statements_using_void_directive.java | if (true) {
System.out.println("everything is well");
}
onlyToEndOfBlock();
| 5,889 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/hiding/hide_halfway_into_class_using_comments.java | prepare();
System.out.println(this + "it seems to work");
| 5,890 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/hiding/hide_parameter_sequence.java | foo(3, 8);
| 5,891 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/hiding/hide_expression_with_explicit_ellipsis.java | foo(3, ...);
| 5,892 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/hiding/hide_statements_with_explicit_ellipsis.java | before();
// ...
after();
| 5,893 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/structs/any_type_never_a_struct.java | functionThatTakesAnAny(Map.of(
"argument", 5)); | 5,894 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/structs/optional_known_struct.java | Vpc.Builder.create(this, "Something")
.argument(5)
.build();
| 5,895 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/structs/var_new_class_unknown_struct.java | Object vpc = Vpc.Builder.create(this, "Something")
.argument(5)
.build();
| 5,896 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/structs/struct_starting_with_i.java | Integration.Builder.create(this, "Something")
.argument(5)
.build();
| 5,897 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/structs/infer_struct_from_union.java | takes(MyProps.builder()
.struct(SomeStruct.builder()
.enabled(false)
.option("option")
.build())
.build()); | 5,898 |
0 | Create_ds/jsii-rosetta/test/translations | Create_ds/jsii-rosetta/test/translations/structs/var_new_class_known_struct.java | Vpc vpc = Vpc.Builder.create(this, "Something")
.argument(5)
.build(); | 5,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.