@Test public void simpleTypes() { assertTrue(Utils.instanceOf("string", "neco")); assertFalse(Utils.instanceOf("string", 3)); assertFalse(Utils.instanceOf("string", new File("/something"))); assertTrue(Utils.instanceOf("integer", 3)); assertTrue(Utils.instanceOf("integer", 0)); assertTrue(Utils.instanceOf("integer", -3)); assertFalse(Utils.instanceOf("integer", "6")); assertFalse(Utils.instanceOf("integer", new File("/something"))); assertTrue(Utils.instanceOf("file", new File("/something"))); assertFalse(Utils.instanceOf("file", "/something")); assertFalse(Utils.instanceOf("file", 3)); }
@Deprecated public static boolean instanceOf(String type, Object object) { if (type.equals("string")) { return object instanceof String; } else if (type.equals("integer")) { return object instanceof Integer; } else if (type.equals("file")) { return object instanceof File; } else if (type.equals("list")) { return object instanceof List; } else if (type.equals("string_list")) { if (object instanceof List) { List list = (List) object; if (list.isEmpty()) { return true; } else { Object firstItem = list.get(0); return firstItem instanceof String; } } else { return false; } } else if (type.equals("file_list")) { if (object instanceof List) { List list = (List) object; if (list.isEmpty()) { return true; } else { Object firstItem = list.get(0); return firstItem instanceof File; } } else { return false; } } else { throw new RuntimeException("Neznámý typ " + type); } }
Utils { @Deprecated public static boolean instanceOf(String type, Object object) { if (type.equals("string")) { return object instanceof String; } else if (type.equals("integer")) { return object instanceof Integer; } else if (type.equals("file")) { return object instanceof File; } else if (type.equals("list")) { return object instanceof List; } else if (type.equals("string_list")) { if (object instanceof List) { List list = (List) object; if (list.isEmpty()) { return true; } else { Object firstItem = list.get(0); return firstItem instanceof String; } } else { return false; } } else if (type.equals("file_list")) { if (object instanceof List) { List list = (List) object; if (list.isEmpty()) { return true; } else { Object firstItem = list.get(0); return firstItem instanceof File; } } else { return false; } } else { throw new RuntimeException("Neznámý typ " + type); } } }
Utils { @Deprecated public static boolean instanceOf(String type, Object object) { if (type.equals("string")) { return object instanceof String; } else if (type.equals("integer")) { return object instanceof Integer; } else if (type.equals("file")) { return object instanceof File; } else if (type.equals("list")) { return object instanceof List; } else if (type.equals("string_list")) { if (object instanceof List) { List list = (List) object; if (list.isEmpty()) { return true; } else { Object firstItem = list.get(0); return firstItem instanceof String; } } else { return false; } } else if (type.equals("file_list")) { if (object instanceof List) { List list = (List) object; if (list.isEmpty()) { return true; } else { Object firstItem = list.get(0); return firstItem instanceof File; } } else { return false; } } else { throw new RuntimeException("Neznámý typ " + type); } }  }
Utils { @Deprecated public static boolean instanceOf(String type, Object object) { if (type.equals("string")) { return object instanceof String; } else if (type.equals("integer")) { return object instanceof Integer; } else if (type.equals("file")) { return object instanceof File; } else if (type.equals("list")) { return object instanceof List; } else if (type.equals("string_list")) { if (object instanceof List) { List list = (List) object; if (list.isEmpty()) { return true; } else { Object firstItem = list.get(0); return firstItem instanceof String; } } else { return false; } } else if (type.equals("file_list")) { if (object instanceof List) { List list = (List) object; if (list.isEmpty()) { return true; } else { Object firstItem = list.get(0); return firstItem instanceof File; } } else { return false; } } else { throw new RuntimeException("Neznámý typ " + type); } }  @Deprecated static boolean instanceOf(String type, Object object); static File buildAbsoluteFile(File parentDir, String filePath); static String computeHash(File file); static Set<String> findLongestCommonSubstrings(String s, String t); static int getLongestCommonSubstringLength(String s, String t); static Identifier extractIdentifierFromDcString(String string); static String mergeStrings(List<String> list, Character separator); static String listToString(List list); static void deleteNonemptyDir(File unzippedDir); static void unzip(File zipFile, File outFolder); }
Utils { @Deprecated public static boolean instanceOf(String type, Object object) { if (type.equals("string")) { return object instanceof String; } else if (type.equals("integer")) { return object instanceof Integer; } else if (type.equals("file")) { return object instanceof File; } else if (type.equals("list")) { return object instanceof List; } else if (type.equals("string_list")) { if (object instanceof List) { List list = (List) object; if (list.isEmpty()) { return true; } else { Object firstItem = list.get(0); return firstItem instanceof String; } } else { return false; } } else if (type.equals("file_list")) { if (object instanceof List) { List list = (List) object; if (list.isEmpty()) { return true; } else { Object firstItem = list.get(0); return firstItem instanceof File; } } else { return false; } } else { throw new RuntimeException("Neznámý typ " + type); } }  @Deprecated static boolean instanceOf(String type, Object object); static File buildAbsoluteFile(File parentDir, String filePath); static String computeHash(File file); static Set<String> findLongestCommonSubstrings(String s, String t); static int getLongestCommonSubstringLength(String s, String t); static Identifier extractIdentifierFromDcString(String string); static String mergeStrings(List<String> list, Character separator); static String listToString(List list); static void deleteNonemptyDir(File unzippedDir); static void unzip(File zipFile, File outFolder);  }