private Candidate createCandidate(String hint) { return new Candidate(AttributedString.stripAnsi(hint), hint, null, null, null, null, true); }
private void addCandidates(final Collection<String> values, final List<Candidate> candidates) { for (final String value : values) { candidates.add(new Candidate(AttributedString.stripAnsi(value), value, null, null, null, null, true)); } } }
cs); for(CharSequence c: cs){ candidates.add(new Candidate((String)c));
when(candidateService.findById( anyInt())).thenReturn(new Candidate());
@Controller public class CandidateController { @ModelAttribute("Candidate") public Candidate getCandidate() { return new Candidate(); } }
<form action="saveCandidate"> <input type="hidden" value="${candidate.id}" name="id" /> name: <input type="text" value="${candidate.name}" name="name" /> @RequestMapping("/saveCandidate") public String saveCandidate(Model model, @ModelAttribute CandidateForm candidateForm) { Candidate candidate = new Candidate(); if(candidateForm.getId() != null) { candidate = candidateService.getById(candidateForm.getId()); // load existed object with relations, so they will be not removed } copyFieldsFromDtoToDomainObject(candidateForm, candidate); candidateService.update(candidate); // I supose that this is actually saveOrUpdate return "candidateMenu"; }
List<Candidate> electionList = new ArrayList<Candidate>(); // create election electionList.add(new Candidate("John Smith", 5000)); electionList.add(new Candidate("Mary Miller", 4000)); electionList.add(new Candidate("Michael Duffy", 6000)); electionList.add(new Candidate("Tim Robinson", 2500)); electionList.add(new Candidate("Joe Ashtony", 1800)); electionList.add(new Candidate("Mickey Jones", 3000)); electionList.add(new Candidate("Rebecca Morgan", 2000)); electionList.add(new Candidate("Kathleen Turner", 8000)); electionList.add(new Candidate("Tory Parker", 500)); electionList.add(new Candidate("Ashton Davis", 10000)); Candidate[] election = electionList.toArray(new Candidate[electionList.size()]);
List<Candidate> candidates = new ArrayList<Candidate>(); candidates.add(new Candidate("One")); candidates.add(new Candidate("Two")); candidates.add(new Candidate("Three")); candidates.add(new Candidate("Four")); int total = 0; foreach(Candidate c : candidates) { c.vote(); total += c.getVoteCount(); } System.out.printf("Votes: %d", total);
public EnumCompleter(Class<? extends Enum<?>> source) { Objects.requireNonNull(source); for (Enum<?> n : source.getEnumConstants()) { candidates.add(new Candidate(n.name().toLowerCase())); } } }
public ConsoleCompletor(CommandCenter commandCenter) { Validate.notNull(commandCenter, "Command center can't be NULL"); this.commandCenter = commandCenter; List<String> commandNames = new ArrayList<String>(commandCenter.getCommandNames()); Collections.sort(commandNames); this.commandNames = new ArrayList<Candidate>(commandNames.size()); for (String commandName : commandNames) { this.commandNames.add(new Candidate(commandName)); } }
public StringsCompleter(Iterable<String> strings) { assert strings != null; for (String string : strings) { candidates.add(new Candidate(AttributedString.stripAnsi(string), string, null, null, null, null, true)); } }
public class EntityLifeCycleTest { @Test public void testLifeCycle() { EntityManager manager = entityManagerFactory.createEntityManager(); Candidate bond = new Candidate("Miss. Bond"); EntityTransaction tx = manager.getTransaction(); tx.begin(); manager.persist(bond); tx.commit(); Assert.assertNotNull(bond.getLifeCycle().getCreatedDate()); manager.close(); } }
private Function<Map<String, List<Candidate>>, Map<String, List<Candidate>>> typoMatcher(String word, int errors, boolean caseInsensitive) { return m -> { Map<String, List<Candidate>> map = m.entrySet().stream() .filter(e -> distance(word, caseInsensitive ? e.getKey() : e.getKey().toLowerCase()) < errors) .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); if (map.size() > 1) { map.computeIfAbsent(word, w -> new ArrayList<>()) .add(new Candidate(word, word, getOriginalGroupName(), null, null, null, false)); } return map; }; }
public CLIPrefixedClassNameCompleter(Collection<String> prefixes) throws IOException { for (String s : getClassNames(prefixes)) { candidates.add(new Candidate(AttributedString.stripAnsi(s), s, null, null, null, null, true)); } }
/** * Completes candidates using all the classes available in the * java <em>CLASSPATH</em>. * * @throws IOException on error */ public ClassNameCompleter() throws IOException { super(getClassNames()); candidates.add( new Candidate(AttributedString.stripAnsi("."), ".", null, null, null, null, true)); }
/** * Completes candidates using all the classes available in the * java <em>CLASSPATH</em>. * * @throws IOException on error */ public ClassNameCompleter() throws IOException { super(getClassNames()); candidates.add( new Candidate(AttributedString.stripAnsi("."), ".", null, null, null, null, true)); }
private void makeCommandCandidates(String cmd, List<Candidate> candidates) { if (service != null && service.getCommandRegistry() != null) { for (Command command : service.getCommandRegistry().getAllCommands()) { String commandName = command.getDescriptor().getName(); if (cmd == null || commandName.indexOf(cmd) == 0) { candidates.add(new Candidate(commandName, commandName, command.getDescriptor().getNamespace(), null, null, null, true)); } } } }
@Test @Transactional(propagation = Propagation.NOT_SUPPORTED) public void testHistoryLogging() { Candidate cand = new Candidate(); cand.setEmail("123@gmail.com"); cand.setFirstName("12"); cand.setLastName("3"); cand = candidateRepository.save(cand); cand.setLastName("34"); candidateRepository.save(cand); assertEquals(entityAuditEventRepository.findAll().size(), 1); }
@Override public void complete(LineReader reader, ParsedLine line, List<org.jline.reader.Candidate> candidates) { CommandLine commandLine = new CommandLineImpl(line); List<Candidate> cands = new ArrayList<>(); completeCandidates(session, commandLine, cands); for (Candidate cand : cands) { candidates.add(new org.jline.reader.Candidate( cand.value(), cand.displ(), cand.group(), cand.descr(), cand.suffix(), cand.key(), cand.complete())); } }
@Override public void complete(LineReader reader, ParsedLine line, List<org.jline.reader.Candidate> candidates) { CommandLine commandLine = new CommandLineImpl(line); List<Candidate> cands = new ArrayList<>(); completeCandidates(session, commandLine, cands); for (Candidate cand : cands) { candidates.add(new org.jline.reader.Candidate( cand.value(), cand.displ(), cand.group(), cand.descr(), cand.suffix(), cand.key(), cand.complete())); } }