List of usage examples for java.lang Object equals
public boolean equals(Object obj)
From source file:Main.java
public static int countValue(String propertyName, Object value, Collection<?> collection) { int count = 0; for (Object o : collection) { BeanWrapper bw = new BeanWrapperImpl(o); Object propertyValue = bw.getPropertyValue(propertyName); if (propertyValue.equals(value)) { count++;// w w w . java 2 s. c o m } } return count; }
From source file:Main.java
public static boolean valueExists(String propertyName, Object value, Collection<?> collection) { for (Object o : collection) { BeanWrapper bw = new BeanWrapperImpl(o); Object propertyValue = bw.getPropertyValue(propertyName); if (propertyValue.equals(value)) { return true; }/*from ww w .j av a 2 s.co m*/ } return false; }
From source file:Main.java
public static JSONObject shallowDiffJSONObjects(JSONObject jo1, JSONObject jo2) throws JSONException { JSONObject result = new JSONObject(); Iterator<String> it = jo2.keys(); while (it.hasNext()) { String key = it.next();//from ww w . j a v a 2 s . com // See if the key is missing or the value is different in the other object Object val1 = jo1.opt(key); Object val2 = jo2.get(key); if (val1 == null || !val2.equals(val1)) result.put(key, val2); } return result; }
From source file:Main.java
public static Collection<?> filterByValue(String propertyName, Object value, Collection<?> collection) { List<Object> list = new ArrayList<Object>(collection.size()); for (Object o : collection) { BeanWrapper bw = new BeanWrapperImpl(o); Object propertyValue = bw.getPropertyValue(propertyName); if (propertyValue.equals(value)) { list.add(o);/*from w w w. j av a 2 s. c om*/ } } return list; }
From source file:Main.java
public static Collection<?> filterByNotValue(String propertyName, Object value, Collection<?> collection) { List<Object> list = new ArrayList<Object>(collection.size()); for (Object o : collection) { BeanWrapper bw = new BeanWrapperImpl(o); Object propertyValue = bw.getPropertyValue(propertyName); if (!propertyValue.equals(value)) { list.add(o);//from w w w . j a va 2 s. c o m } } return list; }
From source file:Main.java
public static int searchIndex(Collection<? extends Object> collection, Object value) { List<? extends Object> valueList = new ArrayList<Object>(collection); int i = 0;// w w w.java 2s . com for (Object o : valueList) { if ((o == value) || ((o != null) && (o.equals(value)))) { return i; } i++; } return -1; }
From source file:Main.java
public static boolean equals(@Nullable Object a, @Nullable Object b) { return a == b || (a != null && a.equals(b)); }
From source file:Main.java
/** * Null-safe testing of two objects for equality. * /*from ww w . j a v a 2 s .c om*/ * @param o1 * object 1 * @param o2 * object 2 * @return <code>true</code> if to objects are equal or if they are both * <code>null</code>. */ public static boolean equals(Object o1, Object o2) { return (o1 == null && o2 == null || o1 != null && o1.equals(o2)); }
From source file:Main.java
public static Set minus(Set oriSet, Set tarSet) { if (oriSet == null || oriSet.size() == 0) return oriSet; if (tarSet == null || tarSet.size() == 0) return oriSet; Iterator oriItor = oriSet.iterator(); Set minusSet = new HashSet(); while (oriItor.hasNext()) { Object oriObj = oriItor.next(); Iterator tarItor = tarSet.iterator(); boolean isExist = false; while (tarItor.hasNext()) { Object tarObj = tarItor.next(); if (tarObj.equals(oriObj)) { isExist = true;//from w ww . j av a2 s.com break; } } if (!isExist) { minusSet.add(oriObj); } } return minusSet; }
From source file:Test.java
private static void serverStart() { try {/*w w w. j av a 2 s.c o m*/ InetSocketAddress hostAddress = new InetSocketAddress(InetAddress.getByName("127.0.0.1"), 2583); AsynchronousServerSocketChannel serverSocketChannel = AsynchronousServerSocketChannel.open() .bind(hostAddress); Future<AsynchronousSocketChannel> serverFuture = serverSocketChannel.accept(); final AsynchronousSocketChannel clientSocket = serverFuture.get(); if ((clientSocket != null) && (clientSocket.isOpen())) { InputStream connectionInputStream = Channels.newInputStream(clientSocket); ObjectInputStream ois = null; ois = new ObjectInputStream(connectionInputStream); while (true) { Object object = ois.readObject(); if (object.equals("EOF")) { clientSocket.close(); break; } System.out.println("Received :" + object); } ois.close(); connectionInputStream.close(); } } catch (Exception e) { e.printStackTrace(); } }