Java Code Examples for org.osgl.util.S#eq()

The following examples show how to use org.osgl.util.S#eq() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Main.java    From di-benchmark with MIT License 6 votes vote down vote up
public static void main(String[] args) {
    int warmUp = WARM_UP;
    int iteration = ITERATION;
    String singletonStr = conf("singleton");
    boolean singleton = S.notBlank(singletonStr) && Boolean.parseBoolean(singletonStr);
    String s = conf("warmup");
    if (S.notBlank(s)) {
        warmUp = Integer.parseInt(s);
    }
    s = conf("iteration");
    if (S.notBlank(s)) {
        iteration = Integer.parseInt(s);
    }
    s = conf("type");
    if (S.eq(s, "runtime")) {
        new RuntimeBenchmark().run(warmUp, iteration, singleton);
    }
    if (S.eq(s, "startup")) {
        new StartupBenchmark().run(warmUp, iteration);
    }
    if (S.eq(s, "split_startup")) {
        new SplitStartupBenchmark().run(iteration);
    }
}
 
Example 2
Source File: JobAnnotationProcessor.java    From actframework with Apache License 2.0 6 votes vote down vote up
private String evaluateExpression(String expression, Class<? extends Annotation> annoClass) {
    String prefix = annoClass.getSimpleName();
    if (S.eq(FixedDelay.class.getName(), prefix)) {
        prefix = "fixed-delay";
    } else {
        prefix = prefix.toLowerCase();
    }
    String ret = expression.trim();
    if (ret.startsWith(prefix)) {
        ret = (String) app().config().get(expression);
        if (S.blank(ret)) {
            throw E.invalidConfiguration("Expression configuration not found: %s", expression);
        }
    }
    return ret;
}
 
Example 3
Source File: ActError.java    From actframework with Apache License 2.0 6 votes vote down vote up
public static SourceInfo loadSourceInfo(StackTraceElement[] stackTraceElements, Class<? extends ActError> errClz) {
    E.illegalStateIf(Act.isProd());
    DevModeClassLoader cl = (DevModeClassLoader) App.instance().classLoader();
    String errClzName = errClz.getName();
    for (StackTraceElement stackTraceElement : stackTraceElements) {
        int line = stackTraceElement.getLineNumber();
        if (line <= 0) {
            continue;
        }
        String className = stackTraceElement.getClassName();
        if (S.eq(className, errClzName)) {
            continue;
        }
        Source source = cl.source(className);
        if (null == source) {
            continue;
        }
        return new SourceInfoImpl(source, line);
    }
    return null;
}
 
Example 4
Source File: SimpleAnnoInvocationHandler.java    From java-di with Apache License 2.0 5 votes vote down vote up
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    String methodName = method.getName();

    if (S.eq("hashCode", methodName)) {
        return hashCode();
    } else if (S.eq("equals", methodName)) {
        return equals(args[0]);
    } else if (S.eq("annotationType", methodName)) {
        return type;
    } else if (S.eq("toString", methodName)) {
        return toString();
    }

    Object result = memberValues.get(methodName);
    if (null != result) {
        return result;
    }

    result = method.getDefaultValue();

    if (result == null) {
        throw new IncompleteAnnotationException(type, methodName);
    }

    return result;
}
 
Example 5
Source File: NamedPort.java    From actframework with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (obj instanceof NamedPort) {
        NamedPort that = (NamedPort) obj;
        return S.eq(that.name, name);
    }
    return false;
}
 
Example 6
Source File: GH325.java    From actframework with Apache License 2.0 5 votes vote down vote up
@GetAction("person/{name};{attributes}/{key}")
public String test2(String name, Map<String, Integer> attributes, String key) {
    if (S.eq("name", key)) {
        return name;
    }
    return S.string(attributes.get(key));
}
 
Example 7
Source File: ControllerClassMetaInfo.java    From actframework with Apache License 2.0 5 votes vote down vote up
public ActionMethodMetaInfo action(String name) {
    if (null == actionLookup) {
        for (ActionMethodMetaInfo act : actions) {
            if (S.eq(name, act.name())) {
                return act;
            }
        }
        return null;
    }
    return actionLookup.get(name);
}
 
Example 8
Source File: MailerConfig.java    From actframework with Apache License 2.0 5 votes vote down vote up
public MailerConfig(String id, Map<String, String> properties, App app) {
    super(app);
    E.illegalArgumentIf(S.blank(id), "mailer config id expected");
    this.id = id;
    this.isDefault = "default".equals(id);
    this.from = getFromConfig(properties);
    this.contentType = getContentTypeConfig(properties);
    this.locale = getLocaleConfig(properties);
    this.subject = getProperty(SUBJECT, properties);
    this.host = getProperty(SMTP_HOST, properties);
    if ("gmail".equals(this.host)) {
        this.host = "smtp.gmail.com";
    }
    this.username = getProperty(SMTP_USERNAME, properties);
    if (null == host) {
        if (S.notBlank(this.username) && this.username.endsWith("gmail.com")) {
            this.host = "smtp.gmail.com";
        } else {
            info("smtp host configuration not found, will use mock smtp to send email");
            mock = true;
        }
    }
    if (!mock) {
        this.useTls = getBooleanConfig(SMTP_TLS, properties) || S.eq("smtp.gmail.com", this.host) || S.eq("smtp-mail.outlook.com", this.host);
        this.useSsl = !this.useTls && getBooleanConfig(SMTP_SSL, properties);
        this.port = getPortConfig(properties);
        this.password = getProperty(SMTP_PASSWORD, properties);
        if (null == username || null == password) {
            warn("Either smtp.username or smtp.password is not configured for mailer[%s]", id);
        }
    }
    this.toList = getEmailListConfig(TO, properties);
    this.ccList = getEmailListConfig(CC, properties);
    this.bccList = getEmailListConfig(BCC, properties);
}
 
Example 9
Source File: MailerClassMetaInfo.java    From actframework with Apache License 2.0 5 votes vote down vote up
public SenderMethodMetaInfo sender(String name) {
    if (null == mailerLookup) {
        for (SenderMethodMetaInfo act : senders) {
            if (S.eq(name, act.name())) {
                return act;
            }
        }
        return null;
    }
    return mailerLookup.get(name);
}
 
Example 10
Source File: Tags.java    From actframework with Apache License 2.0 5 votes vote down vote up
private static boolean isTemplateBounded(String templatePath, String methodPath) {
    int pos = templatePath.indexOf('/');
    if (pos < 0) {
        // must be a free template without package hierarchies
        return false;
    }
    int pos2 = methodPath.indexOf('.');
    if (pos2 != pos) {
        // must be a free template as the first package path doesn't match
        return false;
    }
    String templatePathStartPkg = templatePath.substring(0, pos);
    String methodPathStartPkg = methodPath.substring(0, pos2);
    return S.eq(templatePathStartPkg, methodPathStartPkg);
}
 
Example 11
Source File: ActEventListenerBase.java    From actframework with Apache License 2.0 5 votes vote down vote up
@Override
public final boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj instanceof SysEventListener) {
        SysEventListener that = (SysEventListener) obj;
        return S.eq(that.id(), this.id());
    }
    return false;
}
 
Example 12
Source File: EnvAnnotationVisitor.java    From actframework with Apache License 2.0 5 votes vote down vote up
@Override
public void visitEnd() {
    int arrayValueSize = arrayValue.size();
    if (arrayValueSize > 0) {
        if (S.eq(desc, DESC_REQUIRE_PROFILE) || S.eq(desc, DESC_PROFILE)) {
            matched = Env.profileMatches(arrayValue.toArray(new String[arrayValueSize]));
        } else if (S.eq(desc, DESC_REQUIRE_GROUP) || S.eq(desc, DESC_GROUP)) {
            matched = Env.groupMatches(arrayValue.toArray(new String[arrayValueSize]));
        }
    }
    matched = except ^ matched;
    super.visitEnd();
}
 
Example 13
Source File: EnvAnnotationVisitor.java    From actframework with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(String name, Object value) {
    if ("value".equals(name)) {
        String s = S.string(value);
        if (S.eq(desc, DESC_REQUIRE_MODE) || S.eq(desc, DESC_MODE)) {
            matched = Env.modeMatches(s);
        }
    } else if ("except".equals(name)) {
        except = (Boolean) value;
    }
    super.visit(name, value);
}
 
Example 14
Source File: RotateSecretCrypto.java    From actframework with Apache License 2.0 5 votes vote down vote up
public boolean verifySignature(String message, String signature) {
    if (!rotationEnabled) {
        return S.eq(signature, super.sign(message));
    }
    return S.eq(signature, cur().sign(message))
            || S.eq(signature, prev().sign(message))
            || S.eq(signature, next().sign(message));
}
 
Example 15
Source File: Env.java    From actframework with Apache License 2.0 5 votes vote down vote up
public static boolean groupMatches(String[] groups) {
    final String actGroup = Act.nodeGroup();
    for (String group : groups) {
        if (S.eq(group, actGroup, S.IGNORECASE)) {
            return true;
        }
    }
    return false;
}
 
Example 16
Source File: HMAC.java    From actframework with Apache License 2.0 4 votes vote down vote up
public boolean verifyArgo(String algoName) {
    Algorithm algorithm = algoLookup.get(algoName);
    return null != algorithm && S.eq(this.algoName, algorithm.jwtName());
}
 
Example 17
Source File: ImplicitVariableProvider.java    From actframework with Apache License 2.0 4 votes vote down vote up
String varName() {
    return (null == varName || S.eq(ProvidesImplicitTemplateVariable.DEFAULT, varName)) ? methodName : varName;
}
 
Example 18
Source File: JWT.java    From actframework with Apache License 2.0 4 votes vote down vote up
private boolean verifyIssuer(JSONObject payloads) {
    return S.eq(issuer, payloads.getString("iss"));
}
 
Example 19
Source File: StringOrPattern.java    From actframework with Apache License 2.0 4 votes vote down vote up
public boolean matches(String s) {
    return isPattern() ? this.s.startsWith(S.concat(s, "\\.")) || p.matcher(s).matches() : S.eq(s(), s);
}
 
Example 20
Source File: ClassDetector.java    From actframework with Apache License 2.0 4 votes vote down vote up
private static boolean isAnnotation(Class<? extends Annotation> annoType, String desc) {
    return S.eq(annoType.getName(), Type.getType(desc).getClassName());
}