List of usage examples for java.util Map remove
V remove(Object key);
From source file:com.yahoo.sql4dclient.BeanGenUtil.java
private static void generate(Map<String, String> fields, String beanClassName) { fields.remove("timestamp");// Timestamp is derived from DruidBaseBean so do not create one for it. StringBuilder javaClass = new StringBuilder("/** AUTO-GENERATED **/ \n"); javaClass.append("import com.yahoo.sql4d.sql4ddriver.rowmapper.DruidBaseBean;\n\n"); javaClass.append(String.format("public class %s extends DruidBaseBean { \n", beanClassName)); for (String field : fields.keySet()) { javaClass.append(String.format(" private %s %s ;\n", fields.get(field), field)); }/*from w w w.j ava 2s. c o m*/ for (String field : fields.keySet()) { genGetter(field, fields.get(field), javaClass); genSetter(field, fields.get(field), javaClass); } javaClass.append("} \n"); javaClass.append("/** AUTO-GENERATED **/ \n"); try { FileUtils.write(new File(System.getenv("HOME") + File.separator + beanClassName + ".java"), javaClass); } catch (IOException ex) { logger.error("generate error {}", javaClass.toString(), ex); } logger.info(javaClass.toString()); }
From source file:com.zxy.commons.lang.utils.MapsUtils.java
/** * ?map?{@link BeanUtils#describe(Object)}? * //from w w w .j a va 2s .c om * @param obj * @return map? * @throws IllegalAccessException IllegalAccessException * @throws InvocationTargetException InvocationTargetException * @throws NoSuchMethodException NoSuchMethodException * @see BeanUtils#describe(Object) */ public static Map<?, ?> convertMap(Object obj) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Map<?, ?> map = BeanUtils.describe(obj); // ?key:class, map.remove("class"); return map; }
From source file:Main.java
public static void clearNullElement(Map map) { if (map == null) return;//from w ww .j a va 2 s .c o m Object[] vs = map.keySet().toArray(); for (Object o : vs) { if (null == map.get(o)) map.remove(o); } }
From source file:Main.java
public static void clearNullElement(Map<?, ?> map) { if (map == null) return;// w w w . ja v a2s . com Object[] vs = map.keySet().toArray(); for (Object o : vs) { if (null == map.get(o)) map.remove(o); } }
From source file:Main.java
/** * Remove an element from a map whose values are lists of elements. * @param <T> the type of the keys in the map. * @param <U> the type of the elements in the lists. * @param key the key for the value to remove. * @param value the value to remove.//from w ww. j av a 2 s. c o m * @param map the map from which to remove the key/value pair. */ public static <T, U> void removeFromListMap(T key, U value, Map<T, List<U>> map) { List<U> list = map.get(key); if (list == null) return; list.remove(value); if (list.isEmpty()) map.remove(key); }
From source file:com.centurylink.mdw.util.AuthUtils.java
/** * <p>//w ww .j a va 2 s . co m * Currently uses the metainfo property "Authorization" and checks * specifically for Basic Authentication in a property. * In the future, probably change this. * </p> * <p> * TODO: call this from every protocol channel * If nothing else we should to this to avoid spoofing the AUTHENTICATED_USER_HEADER. * </p> * @param headers * @return */ public static boolean authenticate(Map<String, String> headers, String authMethod) { headers.remove(Listener.AUTHENTICATED_USER_HEADER); // avoid any fishiness -- only we should populate this header String hdr = headers.get(Listener.AUTHORIZATION_HEADER_NAME); if (hdr == null) hdr = headers.get(Listener.AUTHORIZATION_HEADER_NAME.toLowerCase()); if (PropertyManager.getBooleanProperty(PropertyNames.HTTP_BASIC_AUTH_MODE, false)) { // auth required if (hdr == null) { if (ApplicationContext.isDevelopment() && ApplicationContext.getDevUser() != null) { headers.put(Listener.AUTHENTICATED_USER_HEADER, ApplicationContext.getDevUser()); return true; } return false; } else return checkBasicAuthenticationHeader(headers); } else { // auth not required but accepted if (hdr == null) { if (ApplicationContext.isDevelopment() && ApplicationContext.getDevUser() != null) headers.put(Listener.AUTHENTICATED_USER_HEADER, ApplicationContext.getDevUser()); return true; } else return checkBasicAuthenticationHeader(headers); } }
From source file:Main.java
public static Service createService(Context context, ServiceInfo serviceInfo) throws Exception { IBinder token = new Binder(); Class<?> createServiceDataClass = Class.forName("android.app.ActivityThread$CreateServiceData"); Constructor<?> constructor = createServiceDataClass.getDeclaredConstructor(); constructor.setAccessible(true);/*from ww w. j av a 2s . c o m*/ Object createServiceData = constructor.newInstance(); Field tokenField = createServiceDataClass.getDeclaredField("token"); tokenField.setAccessible(true); tokenField.set(createServiceData, token); serviceInfo.applicationInfo.packageName = context.getPackageName(); Field infoField = createServiceDataClass.getDeclaredField("info"); infoField.setAccessible(true); infoField.set(createServiceData, serviceInfo); Class<?> compatibilityClass = Class.forName("android.content.res.CompatibilityInfo"); Field defaultCompatibilityField = compatibilityClass.getDeclaredField("DEFAULT_COMPATIBILITY_INFO"); defaultCompatibilityField.setAccessible(true); Object defaultCompatibility = defaultCompatibilityField.get(null); defaultCompatibilityField.set(createServiceData, defaultCompatibility); Class<?> activityThreadClass = Class.forName("android.app.ActivityThread"); Method currentActivityThreadMethod = activityThreadClass.getDeclaredMethod("currentActivityThread"); Object currentActivityThread = currentActivityThreadMethod.invoke(null); Method handleCreateServiceMethod = activityThreadClass.getDeclaredMethod("handleCreateService", createServiceDataClass); handleCreateServiceMethod.setAccessible(true); handleCreateServiceMethod.invoke(currentActivityThread, createServiceData); Field mServicesField = activityThreadClass.getDeclaredField("mServices"); mServicesField.setAccessible(true); Map mServices = (Map) mServicesField.get(currentActivityThread); Service service = (Service) mServices.get(token); mServices.remove(token); return service; }
From source file:com.querydsl.webhooks.GithubReviewWindow.java
private static void completeAndCleanUp(Map<String, ?> tasks, GHRepository repo, Ref head) { createSuccessMessage(repo, head);//from w w w .ja v a2 s .co m tasks.remove(head.getSha()); }
From source file:Main.java
public static String urlBuilderForGetMethod(Map<String, String> g_map) { StringBuilder sbr = new StringBuilder(); int i = 0;/*from ww w .ja va 2s . c o m*/ if (g_map.containsKey("url")) { sbr.append(g_map.get("url")); g_map.remove("url"); } for (String key : g_map.keySet()) { if (i != 0) { sbr.append("&"); } sbr.append(key + "=" + g_map.get(key)); i++; } System.out.println("Builder url = " + sbr.toString()); return sbr.toString(); }
From source file:io.pivotal.strepsirrhini.chaosloris.destroyer.DestructionScheduler.java
private static Mono<ScheduledFuture<?>> removeSchedule(Map<Long, ScheduledFuture<?>> scheduled, Long id) { return Optional.ofNullable(scheduled.remove(id)) .map((Function<ScheduledFuture<?>, Mono<ScheduledFuture<?>>>) Mono::just).orElse(Mono.empty()); }