List of usage examples for com.google.common.base Predicate Predicate
Predicate
From source file:net.bican.iplib.sample.Sample.java
public static void main(String[] args) { // creating a network range by CIDR address CIDR cidr1 = new CIDR("10.10.10.0/30"); Range<IPAddress> range1 = IPAddresses.fromCIDR(cidr1); // iterating a network range Iterables.all(new AddressIterable(range1), new Predicate<IPAddress>() { @Override/*from w ww.java 2 s . co m*/ public boolean apply(IPAddress input) { System.out.println(input); return true; } }); // creating a network range by netmask Netmask netmask1 = new Netmask("10.10.20.0/255.255.255.0"); Range<IPAddress> range2 = IPAddresses.fromNetmask(netmask1); System.out.println("range contains ip: " + range2.contains(IPAddress.getInstance(InetAddresses.forString("10.10.20.20")))); System.out.println("range contains ip: " + range2.contains(IPAddress.getInstance(InetAddresses.forString("10.10.21.20")))); // creating a network range from an arbitrary interval Range<IPAddress> interval = Range.closed(IPAddress.getInstance(InetAddresses.forString("1.0.0.1")), IPAddress.getInstance(InetAddresses.forString("1.0.2.22"))); Set<Range<IPAddress>> ips = IPAddresses.fromInterval(interval); for (Range<IPAddress> i : ips) { System.out.println(i); } }
From source file:task3.Task3.java
public static void main(String[] args) throws Throwable { JAXBContext jc = JAXBContext.newInstance("task3.book"); Unmarshaller unmarshaller = jc.createUnmarshaller(); Catalog xdml = (Catalog) unmarshaller.unmarshal(new File("Book.xml")); xdml.getBook().remove(xdml.getBook().get(0)); Iterables.removeIf(xdml.getBook(), new Predicate<Book>() { public boolean apply(Book t) { return (t.getGenre().contains("Fan")); }/*from w w w .j ava 2 s .c o m*/ }); xdml.getBook().get(0).setAuthor("Jarne Stroustrup"); for (Book pos : xdml.getBook()) { System.out.println(pos.getAuthor() + " " + pos.getTitle()); } System.out.println("Max elem=" + getMaxPrice(xdml.getBook())); System.out.println("Avrg price=" + getAvrgPrice(xdml.getBook())); System.out.println("Avrg price=" + getOldestBook(xdml.getBook())); }
From source file:com.himanshu.utilities.guava.PredicateListSearchDemo.java
public static void main(String[] args) { List<WrapperA> wrapperAList = new ArrayList<WrapperA>(); wrapperAList.add(new WrapperA("test 1")); wrapperAList.add(new WrapperA("test 2")); wrapperAList.add(new WrapperA("test 3")); List<WrapperA> matchingList = FluentIterable.<WrapperA>from(wrapperAList).filter(new Predicate<WrapperA>() { @Override/* w w w . j ava2 s. c om*/ public boolean apply(WrapperA arg0) { return "test 2".equalsIgnoreCase(arg0.getName()); } }).toList(); System.out.println("Wrapper A: " + wrapperAList); System.out.println("Matching using predicates: " + matchingList); }
From source file:Dictconvert_with_elements.java
public static void main(String args[]) throws Exception { String targetNameSpace = args[1]; String targetNameSpaceVar = args[2]; Map<String, String> namespaces = ImmutableMap.<String, String>of(targetNameSpace, targetNameSpaceVar); HashMap<String, String> keys = new HashMap<String, String>(); DocumentBuilderFactory builderF = DocumentBuilderFactory.newInstance(); builderF.setNamespaceAware(true);//from w w w . jav a 2 s .c om DocumentBuilder builder = builderF.newDocumentBuilder(); Document xmlDictionary = builder.parse(args[0]); for (Map.Entry<String, String> e : namespaces.entrySet()) { System.out.println("XMLCh " + e.getValue() + "[] = {" + Joiner.on(",") .join(Iterables.transform(Lists.charactersOf(e.getKey()), new Function<Character, String>() { public String apply(Character o) { return "\'" + o + "\'"; } })) + ",\'\\0\'};"); } Map<String, String> localKeys = new HashMap<String, String>(); for (Element e : Iterables.filter(getElements(xmlDictionary.getDocumentElement()), new Predicate<Element>() { public boolean apply(Element element) { return element.getAttribute("type").equals("localSet"); } })) { String name = e.getLocalName(); String keyName = "key_" + Joiner.on("").join(e.getAttribute("key").split("\\s")); localKeys.put(keyName, keyName + "_name"); System.out.println("mxfKey " + keyName + " = {" + Joiner.on(",").join(Iterables .transform(Arrays.asList(e.getAttribute("key").split("\\s")), new Function<String, String>() { public String apply(String o) { return "0x" + o; } })) + "};"); System.out.println("XMLCh " + keyName + "_name[] = {" + Joiner.on(",") .join(Iterables.transform(Lists.charactersOf(name), new Function<Character, String>() { public String apply(Character o) { return "\'" + o + "\'"; } })) + ",\'\\0\'};"); //System.out.println("st434dict.insert(std::pair<mxfKey, st434info*>("); //System.out.println('\t' + keyName + ','); //System.out.println("\tnew st434info(/* " + name + " */ " + keyName + "_name, /* " + targetNameSpace + " */ " + namespaces.get(targetNameSpace) + ")"); //System.out.println("));"); for (Element ee : getElements(e)) { String elemKeyName = "key_" + Joiner.on("").join(ee.getAttribute("globalKey").split("\\s")); localKeys.put(elemKeyName, elemKeyName + "_name"); System.out.println("mxfKey " + elemKeyName + " = {" + Joiner.on(",").join(Iterables.transform( Arrays.asList(ee.getAttribute("globalKey").split("\\s")), new Function<String, String>() { public String apply(String o) { return "0x" + o; } })) + "};"); System.out.println("XMLCh " + elemKeyName + "_name[] = {" + Joiner.on(",").join(Iterables .transform(Lists.charactersOf(ee.getLocalName()), new Function<Character, String>() { public String apply(Character o) { return "\'" + o + "\'"; } })) + ",\'\\0\'};"); //System.out.println("st434dict.insert(std::pair<mxfKey, st434info*>("); //System.out.println('\t' + elemKeyName + ','); //System.out.println("\tnew st434info(/* " + ee.getLocalName() + " */ " + elemKeyName + "_name, /* " + targetNameSpace + " */ " + namespaces.get(targetNameSpace) + ")"); //System.out.println("));"); } } if (localKeys.size() > 0) { String arrayName = "arr_" + targetNameSpaceVar; System.out.println("const void* " + arrayName + "[][2] = {"); System.out.println(Joiner.on(", \n").join( Iterables.transform(localKeys.entrySet(), new Function<Map.Entry<String, String>, String>() { @Override public String apply(java.util.Map.Entry<String, String> e) { return "{ &" + e.getKey() + ", " + e.getValue() + " }"; } }))); System.out.println("};"); System.out.println("for (int i=0; i<" + localKeys.size() + ";i++) {"); System.out.println("\tst434dict.insert(std::pair<const mxfKey, st434info*>("); System.out.println("\t*(const mxfKey*)" + arrayName + "[i][0], "); System.out .println("\tnew st434info((const XMLCh*)" + arrayName + "[i][1], " + targetNameSpaceVar + ")"); System.out.println("));"); System.out.println("}"); } }
From source file:com.ondeck.datapipes.examples.SimpleFlowConditionalStepExample.java
public static void main(String[] args) throws FlowException { /**// w w w . ja v a2 s .c o m * oddResultProvider and evenResultProvider are DataProvider steps providing Strings. DataProviderStep are meant * to indicate that the data returned by this type of step is provided as an input of the flow. */ DataProviderStep<String> oddResultProvider = new DataProviderStep<>(TypeToken.of(String.class)); DataProviderStep<String> evenResultProvider = new DataProviderStep<>(TypeToken.of(String.class)); /** * Naming the step since we will be adding 2 String DataProviders to the input of the ExecuteVisitor. */ String oddResultStepName = "oddResult"; oddResultProvider.setName(oddResultStepName); String evenResultStepName = "evenResult"; evenResultProvider.setName(evenResultStepName); /** * integerProvider is a step providing an integer. This integer is provided as an input of the flow. */ DataProviderStep<Integer> integerProvider = new DataProviderStep<>(TypeToken.of(Integer.class)); /** * ConditionalStep allow for conditional branching during the execution of flow. * conditional defined below checks the value provided by the integerProvider step. * If the value is an even number, the evenResultProvider step is executed. * If the value is an odd number, the oddResultProvider is executed. */ ConditionalStep<String, Integer> conditional = new ConditionalStep<>(new Predicate<Integer>() { @Override public boolean apply(Integer input) { return input % 2 == 0; } }, integerProvider, evenResultProvider, oddResultProvider, TypeToken.of(String.class)); String oddString = "I am an odd number"; String evenString = "I am an even number"; Integer[] inputs = { 1, 2 }; for (Integer i : inputs) { /** * Create an ExecuteVisitor to execute the flow. */ SimpleExecuteVisitor<String> executeVisitor = new SimpleExecuteVisitor<>(); /** * Add the inputs to the visitor. Use the step name for the String DataProvider so the executor can differentiates * the two inputs and associate them with the right DataProvider. */ executeVisitor.addInput(oddResultStepName, oddString); executeVisitor.addInput(evenResultStepName, evenString); executeVisitor.addInput(TypeToken.of(Integer.class), i); System.out.println(executeVisitor.execute(conditional)); System.out.println(); } }
From source file:com.cloudbees.api.Main.java
public static void main(String[] args) throws Exception { File beesCredentialsFile = new File(System.getProperty("user.home"), ".bees/bees.config"); Preconditions.checkArgument(beesCredentialsFile.exists(), "File %s not found", beesCredentialsFile); Properties beesCredentials = new Properties(); beesCredentials.load(new FileInputStream(beesCredentialsFile)); String apiUrl = "https://api.cloudbees.com/api"; String apiKey = beesCredentials.getProperty("bees.api.key"); String secret = beesCredentials.getProperty("bees.api.secret"); BeesClient client = new BeesClient(apiUrl, apiKey, secret, "xml", "1.0"); client.setVerbose(false);/*from w ww . j a v a 2 s . c o m*/ URL databasesUrl = Thread.currentThread().getContextClassLoader().getResource("databases.txt"); Preconditions.checkNotNull(databasesUrl, "File 'databases.txt' NOT found in the classpath"); Collection<String> databaseNames; try { databaseNames = Sets.newTreeSet(Resources.readLines(databasesUrl, Charsets.ISO_8859_1)); } catch (Exception e) { throw Throwables.propagate(e); } databaseNames = Collections2.transform(databaseNames, new Function<String, String>() { @Nullable @Override public String apply(@Nullable String input) { // {host_db_create,<<"tco_q5rm">>,<<"TCO_q5rm">>, if (input == null) return null; if (input.startsWith("#")) return null; if (input.indexOf('"') == -1) { logger.warn("Skip invalid line {}", input); return null; } input = input.substring(input.indexOf('"') + 1); if (input.indexOf('"') == -1) { logger.warn("Skip invalid line {}", input); return null; } return input.substring(0, input.indexOf('"')); } }); databaseNames = Collections2.filter(databaseNames, new Predicate<String>() { @Override public boolean apply(@Nullable String s) { return !Strings.isNullOrEmpty(s); } }); Multimap<String, String> databasesByAccount = ArrayListMultimap.create(); Class.forName("com.mysql.jdbc.Driver"); for (String databaseName : databaseNames) { try { DatabaseInfo databaseInfo = client.databaseInfo(databaseName, true); databasesByAccount.put(databaseInfo.getOwner(), databaseInfo.getName()); logger.debug("Evaluate " + databaseInfo.getName()); if (true == false) { // Hibernate logger.info("Hibernate {}", databaseName); Map<String, String> params = new HashMap<String, String>(); params.put("database_id", databaseName); String url = client.getRequestURL("database.hibernate", params); String response = client.executeRequest(url); DatabaseInfoResponse apiResponse = (DatabaseInfoResponse) client.readResponse(response); logger.info("DB {} status: {}", apiResponse.getDatabaseInfo().getName(), apiResponse.getDatabaseInfo().getStatus()); } if (true == false) { // Hibernate logger.info("Activate {}", databaseName); Map<String, String> params = new HashMap<String, String>(); params.put("database_id", databaseName); String url = client.getRequestURL("database.activate", params); String response = client.executeRequest(url); DatabaseInfoResponse apiResponse = (DatabaseInfoResponse) client.readResponse(response); logger.info("DB {} status: {}", apiResponse.getDatabaseInfo().getName(), apiResponse.getDatabaseInfo().getStatus()); } String dbUrl = "jdbc:mysql://" + databaseInfo.getMaster() + "/" + databaseInfo.getName(); logger.info("Connect to {} user={}", dbUrl, databaseInfo.getUsername()); Connection cnn = DriverManager.getConnection(dbUrl, databaseInfo.getUsername(), databaseInfo.getPassword()); cnn.setAutoCommit(false); cnn.close(); } catch (Exception e) { logger.warn("Exception for {}", databaseName, e); } } System.out.println("OWNERS"); for (String account : databasesByAccount.keySet()) { System.out.println(account + ": " + Joiner.on(", ").join(databasesByAccount.get(account))); } }
From source file:es.usc.citius.hipster.examples.EightQueensProblemExample.java
public static void main(String[] args) { // Solve the 8-Queen problem with Hill Climbing and Enforced Hill Climbing final int size = 8; //search problem definition, here we define also //the transition function between states //and the cost (always 0) //and heuristic function (number of attacked queens) SearchProblem<Void, NQueens, WeightedNode<Void, NQueens, Double>> p = ProblemBuilder.create() .initialState(new NQueens(size)) //problem without explicit actions, only a transition function is needed .defineProblemWithoutActions().useTransitionFunction(new StateTransitionFunction<NQueens>() { @Override/*from ww w . j a v a2s .c o m*/ public Iterable<NQueens> successorsOf(NQueens state) { // Generate all possible movements of one queen // There are size*(size-1) available movements Set<NQueens> states = new HashSet<NQueens>(); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { // Change the queen at row i to column j // If i is already in j, then do not add the state if (state.getQueens()[i] != j) { int[] queens = Arrays.copyOf(state.getQueens(), size); queens[i] = j; states.add(new NQueens(queens)); } } } return states; } }).useCostFunction(new CostFunction<Void, NQueens, Double>() { @Override public Double evaluate(Transition<Void, NQueens> transition) { // We assume that the cost of moving a queen is 0 return 0d; } }).useHeuristicFunction(new HeuristicFunction<NQueens, Double>() { @Override public Double estimate(NQueens state) { return (double) state.attackedQueens(); } }).build(); //print some information about the search that will be executed System.out.println( "Random initial state (" + p.getInitialNode().state().attackedQueens() + " attacked queens):"); System.out.println(p.getInitialNode().state()); System.out.println("Running 8-Queens problem with Enforced Hill Climbing and a custom goal test predicate"); //To execute the algorithm we have two options: // Option 1 - Run the algorithm until the predicate is satisfied (until we find a state with score 0, that is, no attacked queens) System.out.println( Hipster.createHillClimbing(p, true).search(new Predicate<WeightedNode<Void, NQueens, Double>>() { @Override public boolean apply(WeightedNode<Void, NQueens, Double> node) { return node.getScore().equals(0d); } })); System.out.println( "Running 8-Queens problem with Enforced Hill Climbing using fine-grained iteration capabilities"); // Option 2 - Manual execution. Expand nodes until we find a state that meets the requirements (no attacked queens) HillClimbing<Void, NQueens, Double, WeightedNode<Void, NQueens, Double>>.EHCIterator it = Hipster .createHillClimbing(p, true).iterator(); int iteration = 0; Double best = it.getBestScore(); while (it.hasNext()) { iteration++; WeightedNode<Void, NQueens, Double> node = it.next(); //System.out.println(node); if (node.getScore().compareTo(best) < 0) { best = node.getScore(); System.out.println("New local minimum found with value " + best + " at iteration " + iteration); } int attacked = node.state().attackedQueens(); //same stop condition than in the Option 1 if (attacked == 0) { System.out.println("Solution found: "); System.out.println(node); break; } } }
From source file:Dictconvert.java
public static void main(String args[]) throws Exception { final ImmutableMap<String, String> nameMap = new ImmutableMap.Builder<String, String>() .put("ebucoreMainFramework", "ebucoreMainFramework") .put("ebucorePartFramework", "ebucorePartFramework") .put("ebucoreMetadataSchemeInformation", "ebucoreMetadataSchemeInformation") /* List mainly generated using AWK: awk '{t=$2; gsub(/ebucore/, "", t); print "\x27"$2"\x27:\x27" tolower(substr(t, 1, 1))substr(t, 2)"\x27," }' < tmp.txt > tmpout.txt *//*from w ww.j av a2s . com*/ .put("ebucoreEntity", "entity").put("ebucoreContact", "contact") .put("ebucoreContactDetails", "details").put("ebucoreAddress", "address") .put("ebucoreRegion", "region").put("ebucoreCompoundName", "compoundName") .put("ebucoreRole", "role").put("ebucoreCountry", "country") .put("ebucoreTextualAnnotation", "textualAnnotation").put("ebucoreBasicLink", "basicLink") .put("ebucoreTypeGroup", "typeGroup").put("ebucoreOrganisation", "organisation") .put("ebucoreOrganisationDepartment", "organisationDepartment") .put("ebucoreCoreMetadata", "coreMetadata").put("ebucoreIdentifier", "identifier") .put("ebucoreTitle", "title").put("ebucoreAlternativeTitle", "alternativeTitle") .put("ebucoreFormatGroup", "formatGroup").put("ebucoreStatusGroup", "statusGroup") .put("ebucoreSubject", "subject").put("ebucoreDescription", "description") .put("ebucoreDate", "date").put("ebucoreDateType", "dateType").put("ebucoreType", "type") .put("ebucoreObjectType", "objectType").put("ebucoreGenre", "genre") .put("ebucoreTargetAudience", "targetAudience").put("ebucoreLanguage", "language") .put("ebucoreCoverage", "coverage").put("ebucoreSpatial", "spatial") .put("ebucoreLocation", "location").put("ebucoreCoordinates", "coordinates") .put("ebucoreTemporal", "temporal").put("ebucorePeriodOfTime", "periodOfTime") .put("ebucoreRights", "rights").put("ebucoreVersion", "version").put("ebucoreRating", "rating") .put("ebucorePublicationHistoryEvent", "publicationHistoryEvent") .put("ebucorePublicationHistory", "publicationHistory") .put("ebucorePublicationChannel", "publicationChannel") .put("ebucorePublicationMedium", "publicationMedium") .put("ebucorePublicationService", "publicationService") .put("ebucoreCustomRelation", "customRelation").put("ebucoreBasicRelation", "basicRelation") .put("ebucorePartMetadata", "partMetadata").put("ebucoreFormat", "format") .put("ebucoreVideoFormat", "videoFormat").put("ebucoreImageFormat", "imageFormat") .put("ebucoreAudioFormat", "audioFormat").put("ebucoreTrack", "track") .put("ebucoreDataFormat", "dataFormat").put("ebucoreCaptioning", "captioning") .put("ebucoreSubtitling", "subtitling").put("ebucoreAncillaryData", "ancillaryData") .put("ebucoreSigningFormat", "signingFormat") .put("ebucoreTechnicalAttributeString", "technicalAttributeString") .put("ebucoreTechnicalAttributeInt8", "technicalAttributeInt8") .put("ebucoreTechnicalAttributeInt16", "technicalAttributeInt16") .put("ebucoreTechnicalAttributeInt32", "technicalAttributeInt32") .put("ebucoreTechnicalAttributeInt64", "technicalAttributeInt64") .put("ebucoreTechnicalAttributeUInt8", "technicalAttributeUInt8") .put("ebucoreTechnicalAttributeUInt16", "technicalAttributeUInt16") .put("ebucoreTechnicalAttributeUInt32", "technicalAttributeUInt32") .put("ebucoreTechnicalAttributeUInt64", "technicalAttributeUInt64") .put("ebucoreTechnicalAttributeFloat", "technicalAttributeFloat") .put("ebucoreTechnicalAttributeRational", "technicalAttributeRational") .put("ebucoreTechnicalAttributeAnyURI", "technicalAttributeAnyURI") .put("ebucoreTechnicalAttributeBoolean", "technicalAttributeBoolean") .put("ebucoreDimension", "dimension").put("ebucoreWidth", "width").put("ebucoreHeight", "height") .put("ebucorePackageInfo", "packageInfo").put("ebucoreMedium", "medium") .put("ebucoreCodec", "codec").put("ebucoreRational", "rational") .put("ebucoreAspectRatio", "aspectRatio").build(); String key_ns_ebucore_1 = "urn:ebu:metadata-schema:smpteclass13/groups/ebucore_2013"; Map<String, String> namespaces = ImmutableMap.<String, String>of(key_ns_ebucore_1, "key_ns_ebucore_1"); HashMap<String, String> keys = new HashMap<String, String>(); DocumentBuilderFactory builderF = DocumentBuilderFactory.newInstance(); builderF.setNamespaceAware(true); DocumentBuilder builder = builderF.newDocumentBuilder(); Document xmlDictionary = builder.parse(args[0]); Map<String, String> localKeys = new HashMap<String, String>(); for (Map.Entry<String, String> e : namespaces.entrySet()) { System.out.println("XMLCh " + e.getValue() + "[] = {" + Joiner.on(",") .join(Iterables.transform(Lists.charactersOf(e.getKey()), new Function<Character, String>() { public String apply(Character o) { return "\'" + o + "\'"; } })) + ",\'\\0\'};"); } for (Element e : Iterables.filter(getElements(xmlDictionary.getDocumentElement()), new Predicate<Element>() { public boolean apply(Element element) { return element.getAttribute("type").equals("localSet"); } })) { String name = nameMap.get(e.getLocalName()); String keyName = "key_" + Joiner.on("").join(e.getAttribute("key").split("\\s")); localKeys.put(keyName, keyName + "_name"); System.out.println("const mxfKey " + keyName + " = {" + Joiner.on(",").join(Iterables .transform(Arrays.asList(e.getAttribute("key").split("\\s")), new Function<String, String>() { public String apply(String o) { return "0x" + o; } })) + "};"); System.out.println("const XMLCh " + keyName + "_name[] = {" + Joiner.on(",") .join(Iterables.transform(Lists.charactersOf(name), new Function<Character, String>() { public String apply(Character o) { return "\'" + o + "\'"; } })) + ",\'\\0\'};"); //System.out.println("st434dict.insert(std::pair<const mxfKey, st434info*>("); //System.out.println('\t' + keyName + ','); //System.out.println("\tnew st434info(/* " + e.getLocalName() + " */ " + keyName + "_name, /* " + key_ns_ebucore_1 + " */ " + namespaces.get(key_ns_ebucore_1) + ")"); //System.out.println("));"); } if (localKeys.size() > 0) { String arrayName = "arr_ebucore_elems"; System.out.println("const void* " + arrayName + "[][2] = {"); System.out.println(Joiner.on(", \n").join( Iterables.transform(localKeys.entrySet(), new Function<Map.Entry<String, String>, String>() { @Override public String apply(java.util.Map.Entry<String, String> e) { return "{ &" + e.getKey() + ", " + e.getValue() + " }"; } }))); System.out.println("};"); System.out.println("for (int i=0; i<" + localKeys.size() + ";i++) {"); System.out.println("\tst434dict.insert(std::pair<const mxfKey, st434info*>("); System.out.println("\t*(const mxfKey*)" + arrayName + "[i][0], "); System.out.println("\tnew st434info((const XMLCh*)" + arrayName + "[i][1], key_ns_ebucore_1)"); System.out.println("));"); System.out.println("}"); } }
From source file:com.stackframe.bentographer.BentoGrapher.java
/** * @param args the command line arguments *///from ww w. j ava 2 s . c om public static void main(String[] args) throws Exception { Class.forName("org.sqlite.JDBC"); File db = findDatabase(); Connection connection = openConnection(db); try { Map<String, Library> libraries = getLibraries(connection); String selected = (String) select(libraries.keySet(), "Choose Library", "Library"); Library library = libraries.get(selected); Collection<Field> fields = getFields(connection, library); fields = Collections2.filter(fields, new Predicate<Field>() { @Override public boolean apply(Field t) { return !ignorableFields.contains(t.type); } }); Comparator<Field> dateComparator = makeTypeComparator("com.filemaker.bento.field.core.date"); Comparator<Field> dateCreatedComparator = makeTypeComparator( "com.filemaker.bento.field.private.timestamp.dateCreated"); Comparator<Field> dateModifiedComparator = makeTypeComparator( "com.filemaker.bento.field.private.timestamp.dateModified"); Ordering<Field> xOrdering = Ordering.from(dateComparator).compound(dateCreatedComparator) .compound(dateModifiedComparator); Collection<Field> sortedXFields = xOrdering.immutableSortedCopy(fields); // FIXME: This depends on the implemenation of Field.toString() returning the type name. It should use a Renderer or something. final Field x = (Field) select(sortedXFields, "Choose X", "X"); fields = Collections2.filter(fields, new Predicate<Field>() { @Override public boolean apply(Field t) { return t != x; } }); Ordering<Field> yOrdering = Ordering.from(Collections.reverseOrder(dateModifiedComparator)) .compound(Collections.reverseOrder(dateCreatedComparator)) .compound(Collections.reverseOrder(dateComparator)); Collection<Field> sortedYFields = yOrdering.immutableSortedCopy(fields); Field y = (Field) select(sortedYFields, "Choose Y", "Y"); // FIXME: Make the rendering of dates smart. It looks like date is seconds since 1/1/2001 and is defined by Core Data. // FIXME: Make the graphs printable. // FIXME: Make it easy to dynamically add more Y values to same graph. // FIXME: Package up a binary that is easy to run. (JNLP/Web Startable?) // FIXME: Publish some screenshots to make it easier to understand what this is for. // FIXME: Make it possible to save graph paramters and automatically bring them back up. // FIXME: Make setting of min as 0 configurable. // FIXME: Fix graph to show actual data points on lines. makeGraph(connection, library, x, y); } finally { connection.close(); } }
From source file:ru.codeinside.gses.activiti.behavior.Transitions.java
public static Predicate<PvmTransition> withPrefix(final String prefix) { return new Predicate<PvmTransition>() { @Override/*from w w w . j a va 2s. c o m*/ public boolean apply(PvmTransition transition) { return transition.getId().toLowerCase().startsWith(prefix); } }; }