public static EffectiveBytes valueOf(int n) { switch (n) { case 1: return ONE; case 2: return TWO; case 3: return THREE; case 4: return FOUR; default : throw E.unexpected("Invalid EffectiveByte value: %s. Expected: 1 - 4", n); } } }
_Periodical(long seconds, boolean startImmediately) { E.illegalArgumentIf(seconds < 1, "delay duration cannot be zero or negative"); this.seconds = seconds; this.startImmediately = startImmediately; }
@Override public void prepareAuthentication(ActionContext context) { throw E.unsupport(); } }
public NamedPort(String name, int port) { E.NPE(name); E.illegalArgumentIf(port < 0); this.name = name; this.port = port; }
@Deprecated public <DI extends DependencyInjector> App injector(DI dependencyInjector) { E.NPE(dependencyInjector); E.illegalStateIf(null != this.dependencyInjector, "Dependency injection factory already set"); throw E.unsupport(); }
@Override public final void setApp(App app) { E.NPE(app); E.illegalStateIf(null != this.app && this.app != app, "%s has already been stamped", this); this.app = app; onAppSet(); }
public static File file(File parent, String path) { try { return new File(parent, path).getCanonicalFile(); } catch (IOException e) { throw E.ioException(e); } } }
public DependencyInjectionBinder(Object source, Class<T> targetClass) { super(source); E.NPE(targetClass); this.targetClass = targetClass; }
public static <T> byte[] serialize(T obj) { E.NPE(obj); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(obj); oos.close(); return baos.toByteArray(); } catch (IOException e) { throw E.ioException(e); } }
public ByteCodeVisitor setDownstream(ClassVisitor cv) { E.illegalStateIf(null != this.cv); this.cv = cv; return this; }
private Class<T> exploreTypeInfo() { List<Type> types = Generics.typeParamImplementations(getClass(), ActProvider.class); int sz = types.size(); E.illegalStateIf(1 != sz, "generic type number not match"); Type type = types.get(0); E.illegalArgumentIf(!(type instanceof Class), "generic type is not a class: %s", type); return (Class) type; }
@Override protected DocumentBuilder initialValue() { try { return builderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw E.invalidConfiguration(e, "error getting DocumentBuilder"); } } };
private static String _get(String key, Properties p) { String s = p.getProperty(key); E.invalidConfigurationIf(null == s, "cannot findBy '%s' setting in project layout properties", key); return s; } }
@Deprecated public <DI extends DependencyInjector> App injector(DI dependencyInjector) { E.NPE(dependencyInjector); E.illegalStateIf(null != this.dependencyInjector, "Dependency injection factory already set"); throw E.unsupport(); }
private static ConsoleReader console(ActionContext actionContext, OutputStream os) { try { return new CliOverHttpConsole(actionContext, os); } catch (IOException e) { throw E.ioException(e); } }
ClassNode(String name, String canonicalName, ClassInfoRepository infoBase) { E.NPE(name, infoBase); this.name = name; this.canonicalName = canonicalName; this.infoBase = infoBase; }
private ByteCodeVisitor setDownstream($.Var<? extends ClassVisitor> cv) { E.illegalStateIf(null != this.cv); _cv = cv; return this; }
private static void validateDir(File dir, String conf) { if (!dir.exists() || !dir.isDirectory() || !dir.canRead()) { E.invalidConfiguration("%s is not a valid directory: %s", conf, dir.getAbsolutePath()); } } }
private static String _get(String key, Properties p) { String s = p.getProperty(key); E.invalidConfigurationIf(null == s, "cannot findBy '%s' setting in project layout properties", key); return s; } }
@Override public void run(Scenario scenario) { try { Thread.sleep(time); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw E.unexpected(e); } }