Java Code Examples for org.rapidoid.u.U#eq()
The following examples show how to use
org.rapidoid.u.U#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: AnyObj.java From rapidoid with Apache License 2.0 | 6 votes |
public static boolean contains(Object arrOrColl, Object value) { if (arrOrColl instanceof Object[]) { Object[] arr = (Object[]) arrOrColl; return Arr.indexOf(arr, value) >= 0; } else if (arrOrColl instanceof Collection<?>) { Collection<?> coll = (Collection<?>) arrOrColl; return coll.contains(value); } else if (arrOrColl == null) { return false; } else { return U.eq(arrOrColl, value); } }
Example 2
Source File: Auth.java From rapidoid with Apache License 2.0 | 6 votes |
public static boolean login(String username, String password) { if (U.isEmpty(username) || password == null) { return false; } if (!Conf.USERS.has(username)) { return false; } Config user = Conf.USERS.sub(username); if (user.isEmpty()) { return false; } String pass = user.entry("password").str().getOrNull(); String hash = user.entry("hash").str().getOrNull(); return (pass != null && U.eq(password, pass)) || (hash != null && Crypto.passwordMatches(password, hash)); }
Example 3
Source File: AbstractCommand.java From rapidoid with Apache License 2.0 | 6 votes |
public boolean clicked() { if (command != null) { IReqInfo req = ReqInfo.get(); if (!req.isGetReq()) { String event = GUI.getCommand(); if (U.notEmpty(event) && U.eq(event, command)) { Object[] args = new Object[cmdArgs.length]; for (int i = 0; i < args.length; i++) { args[i] = U.or(req.data().get("_" + i), ""); } return Arrays.equals(args, cmdArgs); } } } return false; }
Example 4
Source File: AbstractRapidoidMojo.java From rapidoid with Apache License 2.0 | 5 votes |
private static boolean isMainMethod(MethodInfo method) { int flags = method.getAccessFlags(); return method.getName().equals("main") && Modifier.isPublic(flags) && Modifier.isStatic(flags) && U.eq(method.getDescriptor(), "([Ljava/lang/String;)V"); // TODO find more elegant solution }
Example 5
Source File: Radios.java From rapidoid with Apache License 2.0 | 5 votes |
@Override protected Object render() { U.notNull(options, "options"); List<Object> radios = U.list(); for (Object opt : options) { boolean checked = initial != null && U.eq(initial, opt); radios.add(GUI.radio().name(_name()).value(opt).checked(checked).label(str(opt))); } return radios; }
Example 6
Source File: Dropdown.java From rapidoid with Apache License 2.0 | 5 votes |
@Override protected Object render() { U.notNull(options, "options"); SelectTag select = GUI.select().name(_name()).class_("form-control select2"); for (Object opt : options) { boolean initial = this.initial != null && U.eq(this.initial, opt); OptionTag op = GUI.option(opt).value(str(opt)).selected(picked(opt, initial)); select = select.append(op); } return select; }
Example 7
Source File: Form.java From rapidoid with Apache License 2.0 | 5 votes |
public int fieldIndex(String fieldName) { for (int i = 0; i < fields.size(); i++) { if (U.eq(fields.get(i).name, fieldName)) { return i; } } throw U.rte("Cannot find field '%s'!", fieldName); }
Example 8
Source File: HttpUtils.java From rapidoid with Apache License 2.0 | 5 votes |
public static byte[] responseToBytes(Req req, Object result, MediaType contentType, HttpResponseRenderer responseRenderer) { if (U.eq(contentType, MediaType.JSON) || U.eq(contentType, MediaType.XML_UTF_8)) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { responseRenderer.render(req, result, out); } catch (Exception e) { throw U.rte(e); } return out.toByteArray(); } else { return Msc.toBytes(result); } }
Example 9
Source File: TemplateParser.java From rapidoid with Apache License 2.0 | 5 votes |
private static void close(Stack<XNode> stack, String text) { U.must(!stack.isEmpty(), "Empty stack!"); XNode x = stack.pop(); U.must(x.op != XNode.OP.OP_ROOT, "Cannot close a tag that wasn't open: %s", text); if (!U.eq(x.text, text)) { throw U.rte("Expected block: %s, but found: %s", x.text, text); } stack.peek().children.add(x); }
Example 10
Source File: Msc.java From rapidoid with Apache License 2.0 | 5 votes |
public static Class<?> getCallingMainClass() { StackTraceElement[] trace = Thread.currentThread().getStackTrace(); // skip the first 2 elements: // [0] java.lang.Thread.getStackTrace // [1] THIS METHOD for (int i = 2; i < trace.length; i++) { String cls = trace[i].getClassName(); if (couldBeCaller(cls) && U.eq(trace[i].getMethodName(), "main")) { Class<?> clazz = Cls.getClassIfExists(cls); if (clazz != null) { Method main = Cls.findMethod(clazz, "main", String[].class); if (main != null && main.getReturnType() == void.class && !main.isVarArgs() && main.getDeclaringClass().equals(clazz)) { int modif = main.getModifiers(); if (Modifier.isStatic(modif) && Modifier.isPublic(modif)) { return clazz; } } } } } return null; }
Example 11
Source File: AbstractMapImpl.java From rapidoid with Apache License 2.0 | 5 votes |
protected MapEntry<K, V> findEntry(K key, SimpleBucket<MapEntry<K, V>> bucket) { for (int i = 0; i < bucket.size(); i++) { MapEntry<K, V> entry = bucket.get(i); if (entry != null && U.eq(entry.key, key)) { return entry; } } return null; }
Example 12
Source File: GroupOf.java From rapidoid with Apache License 2.0 | 5 votes |
public E find(String id) { U.notNull(id, "id"); for (E item : items) { if (U.eq(id, item.id())) return item; } return null; }
Example 13
Source File: Manageables.java From rapidoid with Apache License 2.0 | 5 votes |
private static Manageable findById(List<? extends Manageable> items, String id) { U.notNull(id, "id"); for (Manageable item : items) { if (U.eq(id, item.id())) return item; } return null; }
Example 14
Source File: Arr.java From rapidoid with Apache License 2.0 | 5 votes |
public static int indexOf(Object[] arr, Object value) { for (int i = 0; i < arr.length; i++) { if (U.eq(arr[i], value)) { return i; } } return -1; }
Example 15
Source File: GUI.java From rapidoid with Apache License 2.0 | 4 votes |
public static boolean isEvent() { IReqInfo req = req(); return U.eq(req.params().get("__event__"), "true"); }
Example 16
Source File: AbstractPageMenuItem.java From rapidoid with Apache License 2.0 | 4 votes |
void setActiveUri(String uri) { active = U.eq(uri, target); }
Example 17
Source File: ClasspathScanner.java From rapidoid with Apache License 2.0 | 4 votes |
private static boolean shouldScanJAR(String jar) { String filename = new File(jar).getName(); return !filename.equalsIgnoreCase("rapidoid.jar") && (!ClasspathUtil.hasAppJar() || U.eq(jar, ClasspathUtil.appJar())); }
Example 18
Source File: BasicUtils.java From rapidoid with Apache License 2.0 | 4 votes |
public static boolean eq(Object a, Object b) { return U.eq(a, b); }