code
stringlengths
146
466k
prompt
stringlengths
54
1.5k
Of course, here is the Java code you requested: ```java public Bills getByBillNumber(String billNumber) throws VoteSmartException, VoteSmartErrorException { return api.query("Votes.getByBillNumber", new ArgMap("billNumber", billNumber), Bills.class ); } ``` Hope this helps!
Create a Java method that does the following: "Get all votes by bill number".
Of course, here is the Java code you requested: ```java public Bills getBillsByCategoryYearState(String categoryId, String year) throws VoteSmartException, VoteSmartErrorException { return api.query("Votes.getBillsByCategoryYearState", new ArgMap("categoryId", categoryId, "year", year), Bills.class ); } ``` Hope...
Create a Java method that does the following: "Get Bills by category and year state.".
Of course, here is the Java code you requested: ```java public Bills getBillsBySponsorYear(String candidateId, String year) throws VoteSmartException, VoteSmartErrorException { return api.query("Votes.getBillsBySponsorYear", new ArgMap("candidateId", candidateId, "year", year), Bills.class ); } ``` Hope this hel...
Create a Java method that does the following: "Get a list of bills for a candidate s year.".
Of course, here is the Java code you requested: ```java public Bills getBillsBySponsorCategory(String candidateId, String categoryId) throws VoteSmartException, VoteSmartErrorException { return api.query("Votes.getBillsBySponsorCategory", new ArgMap("candidateId", candidateId, "categoryId", categoryId), Bills.class...
Create a Java method that does the following: "Get a list of bills for a candidate.".
Of course, here is the Java code you requested: ```java public BillVetoes getVetoes(String candidateId) throws VoteSmartException, VoteSmartErrorException { return api.query("Votes.getVetoes", new ArgMap("candidateId", candidateId), BillVetoes.class ); } ``` Hope this helps!
Create a Java method that does the following: "Get the list of votes for a candidate.".
Of course, here is the Java code you requested: ```java public State getState(String stateId) throws VoteSmartException, VoteSmartErrorException { return api.query("State.getState", new ArgMap("stateId", stateId), State.class ); } ``` Hope this helps!
Create a Java method that does the following: "Get the state with the given id.".
Of course, here is the Java code you requested: ```java public Npat getNpat(String candidateId) throws VoteSmartException, VoteSmartErrorException { return api.query("Npat.getNpat", new ArgMap("candidateId", candidateId), Npat.class ); } ``` Hope this helps!
Create a Java method that does the following: "Get Npat for a candidate.".
Of course, here is the Java code you requested: ```java private int realRead(byte[] b, int off, int len) throws IOException { int lenToRead = rateHelper.take(len); int rd = real.read(b, off, lenToRead); if (rd != lenToRead) rateHelper.giveBack(lenToRead - rd); return rd; } ``` Hop...
Create a Java method that does the following: "Read bytes from the underlying input stream.".
Of course, here is the Java code you requested: ```java @Override public int read(byte[] b, int off, int len) throws IOException { int done = 0; while (done < len && (done == 0 || available() > 0 || (boring && real.available() > 0))) done += realRead(b, off + done, Math.min(len - done, Math.max...
Create a Java method that does the following: "read from the underlying stream".
Of course, here is the Java code you requested: ```java public static void sleep(int ms) { long deadline = System.currentTimeMillis() + ms; while (System.currentTimeMillis() < deadline) { try { Thread.sleep(Math.max(1, (deadline - System.currentTimeMillis()) / 2)); } catch (In...
Create a Java method that does the following: "Sleep for the specified number of milliseconds.".
Of course, here is the Java code you requested: ```java public int take(int n) { int lenToTake; while (true) { int stored = spent.get(); lenToTake = Math.min(n, thingsPerTick - stored); if (stored >= thingsPerTick) sleep(); else if (spent.compareAndSet(stored...
Create a Java method that does the following: "Take n times from the queue.".
Of course, here is the Java code you requested: ```java public static Result calculate(long nanoseconds, float epsilon) { if (epsilon <= 0 || epsilon >= 1) throw new IllegalArgumentException("0 < epsilon < 1 not satisfied"); long max_divider = (int) (1D / epsilon); if (nanoseconds < max_div...
Create a Java method that does the following: "Calculate the number of nanoseconds for a given number of nanoseconds.".
Of course, here is the Java code you requested: ```java @Override public void removeListener(TickListener listener) { super.removeListener(listener); if (listeners.isEmpty() && !keepAlive) stop(); } ``` Hope this helps!
Create a Java method that does the following: "Removes a listener from the list of listeners.".
Of course, here is the Java code you requested: ```java public static Result calculate(float rateBytesPerSecond, int minInterval) { BigDecimal B_MIN = BigDecimal.ONE; BigDecimal B_MAX = BigDecimal.valueOf(MAX_BYTES_PER_TICK); BigDecimal I_MIN = BigDecimal.valueOf(minInterval); BigDecimal I_MAX ...
Create a Java method that does the following: "Calculate the rate of the given number of bytes per second".
Of course, here is the Java code you requested: ```java public static RateLimitOutputStream limitRate(OutputStream base, TickSource tickSource, int bytesPerTick, int prescaler) { return new RateLimitOutputStream(base, tickSource, bytesPerTick, prescaler); } ``` Hope this helps!
Create a Java method that does the following: "Limit the output stream to a given number of bytes.".
Of course, here is the Java code you requested: ```java public void waitFor() throws Throwable { while (!finished) { try { synchronized (this) { this.wait(100); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); }...
Create a Java method that does the following: "Wait for the completion of the task.".
Of course, here is the Java code you requested: ```java private int realWrite(byte[] b, int off, int len) throws IOException { int lenToWrite = rateHelper.take(len); real.write(b, off, lenToWrite); return lenToWrite; } ``` Hope this helps!
Create a Java method that does the following: "Write a byte array to the underlying stream.".
Of course, here is the Java code you requested: ```java private static <K, V> Collector<Map.Entry<K, V>, ?, List<Map<K, V>>> mapSizer(int limit) { return Collector.of(ArrayList::new, (l, e) -> { if (l.isEmpty() || l.get(l.size() - 1).size() == limit) { ...
Create a Java method that does the following: "Collect a list of maps of the given size.".
Of course, here is the Java code you requested: ```java public static <K, V> Map<K, V> sort(Map<K, V> map, Comparator<Map.Entry<K, V>> comparator) { Assert.notNull(map, "Missing map!"); Assert.notNull(comparator, "Missing comparator!"); List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet()); Collectio...
Create a Java method that does the following: "Sort the given map using the given comparator.".
Of course, here is the Java code you requested: ```java public static <T> T firstValue(Map<String, T> map) { if (map == null || map.size() == 0) { return null; } String firstKey = map.keySet().iterator().next(); return map.get(firstKey); } ``` Hope this helps!
Create a Java method that does the following: "Get the first value from the map.".
Of course, here is the Java code you requested: ```java public static <T> void isNull(T test, String message) { isTrue(test == null, message); } ``` Hope this helps!
Create a Java method that does the following: "Test if object is null.".
Of course, here is the Java code you requested: ```java public static <T> void notNull(T test, String message) { isFalse(test == null, message); } ``` Hope this helps!
Create a Java method that does the following: "Test if object is not null.".
Of course, here is the Java code you requested: ```java public static void notNullOrEmptyTrimmed(String value, String message) { isFalse(StringUtils.isNullOrEmptyTrimmed(value), message); } ``` Hope this helps!
Create a Java method that does the following: "Test if the string is not null or empty and not empty.".
Of course, here is the Java code you requested: ```java public static <T> void notNullOrEmpty(Set<T> set, String message) { isFalse(set == null || set.size() == 0, message); } ``` Hope this helps!
Create a Java method that does the following: "Check that the set is not null or empty.".
Of course, here is the Java code you requested: ```java public static <T> void notNullOrEmpty(T[] array, String message) { isFalse(array == null || array.length == 0, message); } ``` Hope this helps!
Create a Java method that does the following: "Check that an array is not null or empty.".
Of course, here is the Java code you requested: ```java public static <T> void isNullOrEmpty(List<T> list, String message) { isTrue(list == null || list.size() == 0, message); } ``` Hope this helps!
Create a Java method that does the following: "Test if list is null or empty.".
Of course, here is the Java code you requested: ```java public static <T> void isNullOrEmpty(Set<T> set, String message) { isTrue(set == null || set.size() == 0, message); } ``` Hope this helps!
Create a Java method that does the following: "Test if set is null or empty.".
Of course, here is the Java code you requested: ```java @Deprecated public static String getResourceAsString(String resourceFile, Class clazz) { Assert.notNullOrEmptyTrimmed(resourceFile, "Missing resource file!"); Scanner scanner = null; try { InputStream resource = clazz.getResourceAsStream(resourceFile...
Create a Java method that does the following: "Get the contents of a resource as a String.".
Of course, here is the Java code you requested: ```java @Deprecated public static Long getLastModifiedTime(String resourceFile, Class clazz) { Assert.notNullOrEmptyTrimmed(resourceFile, "Missing resource file!"); try { URL url = clazz.getResource(resourceFile); return url.openConnection().getLastModified...
Create a Java method that does the following: "Get last modified time of a resource file.".
Of course, here is the Java code you requested: ```java public static String getString(final InputStream is, String encoding) { if (is == null) { return null; } if (StringUtils.isNullOrEmptyTrimmed(encoding)) { encoding = UTF_8; } final char[] buffer = new char[BUFFER_SIZE]; final StringBuilder ou...
Create a Java method that does the following: "Gets the string from the given input stream.".
Of course, here is the Java code you requested: ```java @Deprecated public static String getResourceAbsolutePath(String resource, Class clazz) { Assert.notNullOrEmptyTrimmed(resource, "Missing resource name!"); URL file = clazz.getResource(resource); Assert.notNull(file, "Resource: '" + resource + "', not fou...
Create a Java method that does the following: "Get absolute path of resource.".
Of course, here is the Java code you requested: ```java public static long generateLong(int length) { if (length <= 0 || length > 19) { throw new IllegalArgumentException("Can't generate random id with length: " + length); } SecureRandom random = new SecureRandom(); StringBuilder sb = new StringBuilder(le...
Create a Java method that does the following: "Generates a long with the specified length.".
Of course, here is the Java code you requested: ```java public static String formatDateTime(long time) { Instant instant = Instant.ofEpochMilli(time); return formatDateTime(instant); } ``` Hope this helps!
Create a Java method that does the following: "Format a long time as a date time string.".
Of course, here is the Java code you requested: ```java public static String formatDate(long time) { Instant instant = Instant.ofEpochMilli(time); return DATE_FORMAT.format(instant); } ``` Hope this helps!
Create a Java method that does the following: "Format a time value as a date string.".
Of course, here is the Java code you requested: ```java public static String formatDate(Instant time) { Assert.notNull(time, "Missing time!"); return DATE_FORMAT.format(time); } ``` Hope this helps!
Create a Java method that does the following: "Format a time as a string.".
Of course, here is the Java code you requested: ```java public static String format(long time, DateTimeFormatter format) { return format(Instant.ofEpochMilli(time), format); } ``` Hope this helps!
Create a Java method that does the following: "Format a long time with the specified format.".
Of course, here is the Java code you requested: ```java public static OffsetDateTime toOffsetDateTime(long timestamp, ZoneId zoneId) { Instant time = Instant.ofEpochMilli(timestamp); return toOffsetDateTime(time, zoneId); } ``` Hope this helps!
Create a Java method that does the following: "Converts a timestamp to an offset date time.".
Of course, here is the Java code you requested: ```java public static Instant getMonthStart(Instant time) { Assert.notNull(time, "Missing date time"); LocalDateTime dateTime = LocalDateTime.ofInstant(time, ZoneOffset.UTC); dateTime = dateTime.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).with(Chrono...
Create a Java method that does the following: "Gets the month start of the specified date time.".
Of course, here is the Java code you requested: ```java public static String trimDoubleSpaces(String value) { if (isNullOrEmpty(value)) { return value; } value = value.trim(); return value.replaceAll("\\s+", " "); } ``` Hope this helps!
Create a Java method that does the following: "Trims double spaces in a string.".
Of course, here is the Java code you requested: ```java public static String trimToNull(String text) { text = trim(text); if (text == null || text.isEmpty()) { return null; } return text; } ``` Hope this helps!
Create a Java method that does the following: "Trims the given string and returns the result as a String.".
Of course, here is the Java code you requested: ```java public static String join(List<?> list, String separator) { return join(list, separator, null); } ``` Hope this helps!
Create a Java method that does the following: "Join a list of strings using the given separator.".
Of course, here is the Java code you requested: ```java public static String join(List<?> list, String separator, Integer limit) { if (separator == null || separator.equalsIgnoreCase("")) { throw new IllegalArgumentException("Missing separator!"); } StringBuilder output = new StringBuilder(); if (limit ==...
Create a Java method that does the following: "Join a list of strings with a separator.".
Of course, here is the Java code you requested: ```java public static String join(Object[] args, String separator, Integer limit) { if (separator == null || separator.equalsIgnoreCase("")) { throw new IllegalArgumentException("Missing separator!"); } if (args != null && args.length > 0) { List<Object> ar...
Create a Java method that does the following: "Join an array of objects with a separator.".
Of course, here is the Java code you requested: ```java public static String join(Object[] args, String separator) { return join(args, separator, null); } ``` Hope this helps!
Create a Java method that does the following: "Join an array of objects with a separator.".
Of course, here is the Java code you requested: ```java public static String join(Set<?> items, String separator) { return join(items, separator, null); } ``` Hope this helps!
Create a Java method that does the following: "Join a set of items with a separator.".
Of course, here is the Java code you requested: ```java public static <T, V> String join(Map<T, V> map, String separator) { if (separator == null || separator.equalsIgnoreCase("")) { throw new IllegalArgumentException("Missing separator!"); } StringBuilder output = new StringBuilder(); if (map != null) { ...
Create a Java method that does the following: "Joins the contents of a map with a separator.".
Of course, here is the Java code you requested: ```java public static List<String> getWords(String text) { List<String> output = new ArrayList<>(); if (isNullOrEmptyTrimmed(text)) { return output; } Pattern p = Pattern.compile("\\b\\p{L}+\\b"); Matcher m = p.matcher(text); while (m.find()) { outpu...
Create a Java method that does the following: "Get words from text.".
Of course, here is the Java code you requested: ```java public static List<String> split(String text, String regEx) { if (isNullOrEmptyTrimmed(text)) { return Collections.emptyList(); } String[] items = text.trim().split(regEx); return Arrays.asList(items); } ``` Hope this helps!
Create a Java method that does the following: "Split the given text into a list of strings.".
Of course, here is the Java code you requested: ```java public static String trimTextDown(String text, int size) { if (text == null || text.length() <= size) { return text; } int pos = text.lastIndexOf(" ", size); if (pos < 0) { return text.substring(0, size); } return text.substring(0, pos); } ...
Create a Java method that does the following: "Trims the text down to the specified size.".
Of course, here is the Java code you requested: ```java public static int relevance(String value, String search) { if (StringUtils.isNullOrEmptyTrimmed(value) || StringUtils.isNullOrEmptyTrimmed(search)) { return -1; } if (search.length() > value.length()) { return -1; } int relevance = -1; // st...
Create a Java method that does the following: "Returns the relevance of the first occurrence of the search string in the value.".
Of course, here is the Java code you requested: ```java public static String sanitizeWhitespace(String input) { Assert.notNull(input, "Missing input!"); input = input.replaceAll("\\s+", " "); return input.trim(); } ``` Hope this helps!
Create a Java method that does the following: "Sanitize whitespace.".
Of course, here is the Java code you requested: ```java public static String unQuote(String text) { if (isNullOrEmptyTrimmed(text)) { return text; } if ((text.startsWith("\"") && text.endsWith("\"")) || (text.startsWith("'") && text.endsWith("'"))) { return text.substring(1, text.length() - 1); }...
Create a Java method that does the following: "Un - quotes a string.".
Of course, here is the Java code you requested: ```java public static String formatDateTimeShort(long time) { SimpleDateFormat format = getDateTimeFormat(); Calendar calendar = getCalendar(time); return format.format(calendar.getTime()); } ``` Hope this helps!
Create a Java method that does the following: "Format a long time as a date time string.".
Of course, here is the Java code you requested: ```java public static String formatDate(long time) { SimpleDateFormat format = getDateFormat(); Calendar calendar = getCalendar(time); return format.format(calendar.getTime()); } ``` Hope this helps!
Create a Java method that does the following: "Format a time value as a string.".
Of course, here is the Java code you requested: ```java public static long getTimestamp(String value, SimpleDateFormat[] formats) { Assert.notNull(formats, "Missing date time formats"); Assert.isTrue(formats.length > 0, "Missing date time formats"); if (StringUtils.isNullOrEmptyTrimmed(value)) { return 0; ...
Create a Java method that does the following: "Get the timestamp value from the given string using the given formats.".
Of course, here is the Java code you requested: ```java public List<Integer> hasTag(final Integer tagID) { final List<Integer> retValue = new ArrayList<Integer>(); for (final FilterTag tag : getFilterTags()) { if (tag.getTag().getTagId().equals(tagID)) retValue.add(tag.getTagState()); ...
Create a Java method that does the following: "Gets the list of tag states.".
Of course, here is the Java code you requested: ```java @SuppressWarnings("PMD") public void add(final Statement... toAdd) { if (toAdd != null) { Arrays.stream(toAdd) .filter(Objects::nonNull) .forEach(c -> { // Resolve the type...
Create a Java method that does the following: "Add a list of statements to the current one.".
Of course, here is the Java code you requested: ```java public Node findNode(final String identifier, final boolean recursive) { Optional<Node> toReturn = getNodes().stream().filter(c -> c.getId().equals(identifier)).findFirst(); if (!toReturn.isPresent() && recursive && getSubgraphs() != null && !get...
Create a Java method that does the following: "Find a Node in the graph.".
Of course, here is the Java code you requested: ```java public Edge findEdge(final String fromId, final String toId, final boolean recursive) { Optional<Edge> toReturn = getEdges().stream() .filter(c -> c.getId().equals(fromId) && c.getRightSideEdge().getId().equals(toId)) .fin...
Create a Java method that does the following: "Find the edge with the given identifier.".
Of course, here is the Java code you requested: ```java public Edge addEdge(final String fromId, final String toId, final Graph parentGraph) { // Check sanity if (fromId == null || fromId.isEmpty()) { throw new IllegalArgumentException("Cannot handle null or empty 'fromId' argument."); ...
Create a Java method that does the following: "Add an edge to the graph.".
Of course, here is the Java code you requested: ```java private static Map<String, Set> compareAndAggregate(Map sourceMap, Map targetMap) { //keys witch values are different System.out.println("compare maps"); System.out.println("source: " + sourceMap); System.out.println("target: " + t...
Create a Java method that does the following: "Compare two maps and return the aggregation info".
Of course, here is the Java code you requested: ```java @Transient public String getTopicSearchText() { if (topicXML == null) return ""; final Source source = new Source(topicXML); source.fullSequentialParse(); return source.getTextExtractor().toString(); } ``` Hope this helps...
Create a Java method that does the following: "Get the text of the topic search.".
Of course, here is the Java code you requested: ```java public void iconSeverity(String level, int textType) { sink.figure(); sink.figureGraphics("images/icon_" + level + "_sml.gif"); sink.figure_(); if (textType > 0) { sink.nonBreakingSpace(); sink.text(bundle...
Create a Java method that does the following: "Icon severity.".
Of course, here is the Java code you requested: ```java @Transient public String getTagsList(final boolean brLineBreak) { // define the line breaks for html and for tooltips final String lineBreak = brLineBreak ? "<br/>" : "\n"; final String boldStart = brLineBreak ? "<b>" : ""; fin...
Create a Java method that does the following: "Gets the tags list.".
Of course, here is the Java code you requested: ```java public static <T extends AuditedEntity> Date getFixedLastModifiedDate(final EntityManager entityManager, final T entity) { return entity.getLastModifiedDate() != null ? entity.getLastModifiedDate() : getLatestRevisionDate(entityManager, entity); } ```...
Create a Java method that does the following: "Gets the fixed last modified date.".
Of course, here is the Java code you requested: ```java public Node find(String host, int port) { return socketToNodeMap.get(Utils.toKey(host, port)); } ``` Hope this helps!
Create a Java method that does the following: "Find the node with the given host and port.".
Of course, here is the Java code you requested: ```java public Set<Node> getAllNotDead() { Set<Node> allNotDeadNodesSet = new HashSet<Node>(); for (Node node : socketToNodeMap.values()) { if (!NodeStatus.DEAD.equals(node.getStatus())) { allNotDeadNodesSet.add(node); } } return allNotDeadNodesSet; ...
Create a Java method that does the following: "Get all nodes that are not dead.".
Of course, here is the Java code you requested: ```java public void add(Node node) { socketToNodeMap.put(Utils.toKey(node), node); sendEvent(node, NodeEventType.ADDED); } ``` Hope this helps!
Create a Java method that does the following: "Add a node to the node list.".
Of course, here is the Java code you requested: ```java public void remove(Node node) { socketToNodeMap.remove(Utils.toKey(node)); sendEvent(node, NodeEventType.REMOVED); } ``` Hope this helps!
Create a Java method that does the following: "Remove a node from the node list.".
Of course, here is the Java code you requested: ```java public <Concept, S extends Statement> AbstractStatementConverter<Concept, S> get( final Class<Concept> conceptClass) { // Check sanity if (conceptClass == null) { throw new NullPointerException("Cannot handle null 'concept...
Create a Java method that does the following: "Get a statement converter for a given concept class.".
Of course, here is the Java code you requested: ```java private void configureResourceLocator(final ResourceManager resourceManager, final CheckstyleExecutorRequest request, final List<Artifact> additionalArtifacts) { final Mav...
Create a Java method that does the following: "Configure the resource locator.".
Of course, here is the Java code you requested: ```java @Override public boolean start(final RootDoc root) { // Check sanity if (this.dotFacade == null) { throw new IllegalStateException("The DotFacade cannot be null."); } // Wrap the received RootDoc instance. ...
Create a Java method that does the following: "Override start to start the Doclet.".
Of course, here is the Java code you requested: ```java public T build(Object... attributes) { List<Object> attributeList = new ArrayList<Object>(Arrays.asList(attributes)); //kinda wacky but Arrays.asList returns a unmodifiable list String[] traitNames = getTraitNames(attributeList); applyTra...
Create a Java method that does the following: "Build an object from the supplied attributes.".
Of course, here is the Java code you requested: ```java private void setProperty(Object target, String name, Object value) { if(! ReflectionUtils.setProperty(target, name, getValue(value))) { // no property was found, try to set the field directly setField(target, name, value); ...
Create a Java method that does the following: "Set a property on the target object.".
Of course, here is the Java code you requested: ```java private Map<String, Object> createObjectPropertyValues(Map<String, Object> defaultPropertyValues, List<Object> attributes) { Map<String, Object> propertyValues = new HashMap<String, Object>(defaultPropertyValues); if(attributes != null) { ...
Create a Java method that does the following: "Create a map of property values from a list of attributes.".
Of course, here is the Java code you requested: ```java private int currentSequence(String name) { Map<String, Integer> sequencesForClass = sequences.get(getClass()); if(sequencesForClass == null) { sequencesForClass = new HashMap<String, Integer>(); sequences.put(getClass(), se...
Create a Java method that does the following: "Gets the current sequence number for a class.".
Of course, here is the Java code you requested: ```java @Override protected String doRender(final RenderConfiguration config, final CommonNodeAttributes entity) { return config.getIndent() + entity.getId() + " " + attributeRenderer.render(config, entity.getAttributes()); ...
Create a Java method that does the following: "Render the node.".
Of course, here is the Java code you requested: ```java public List<NodeEvent> getAndClearEventslist() { ArrayList<NodeEvent> result = new ArrayList<NodeEvent>(eventslist); eventslist.clear(); return result; } ``` Hope this helps!
Create a Java method that does the following: "Gets and clear the eventslist.".
Of course, here is the Java code you requested: ```java public static boolean containsVisualizationDocletTag(final String message) { if (message != null) { for (VisualizationDocletTag current : VisualizationDocletTag.values()) { if (message.contains(current.toString() + " ")) { ...
Create a Java method that does the following: "Checks if the given message contains a visualization javadoc tag.".
Of course, here is the Java code you requested: ```java public SortedSet<PackageDoc> findPackagesFromClassesInJavaDocRun() { final SortedSet<PackageDoc> toReturn = new TreeSet<>(Comparators.PACKAGE_NAME_COMPARATOR); final ClassDoc[] currentExecutionClasses = classes(); if (currentExecutionCla...
Create a Java method that does the following: "Find packages from classes in JavaDocRun.".
Of course, here is the Java code you requested: ```java protected static void checkParentConstructor(Class<?> clazz) throws InvalidClassException { if (clazz != Object.class) { Class<?> parentClazz = clazz.getSuperclass(); try { checkConstructorNoArg(parentClazz); ...
Create a Java method that does the following: "Check that the parent constructor of the given class is a constructor of the class that is not an instance of Object. class.".
Of course, here is the Java code you requested: ```java protected static Map<String, Method> getPropertyGetters(Class<?> clazz) { //todo: clazz.getDeclaredMethods() + hierarchy up OR clazz.getMethods()? Map<String, Method> result = new HashMap<String, Method>(); if (clazz != Object.class) { ...
Create a Java method that does the following: "Get the property getters for a class.".
Of course, here is the Java code you requested: ```java private static boolean existsClass(String clsName, ClassLoader clsLoader) { String resource = clsName.replace('.', '/'); return clsLoader.getResource(resource) != null; } ``` Hope this helps!
Create a Java method that does the following: "Checks if the class exists in the class loader.".
Of course, here is the Java code you requested: ```java @Override @SuppressWarnings("PMD.PreserveStackTrace") protected void performValidation(final MavenProject project, final EnforcerRuleHelper helper) throws RuleFailureException { try { ProjectType.getProjectType(project); ...
Create a Java method that does the following: "Perform validation.".
Of course, here is the Java code you requested: ```java @Override public void execute(FunctionContext functionContext) { Map<String, Object> args = (HashMap) functionContext.getArguments(); String regionName = (String) args.get("regionName"); Region region = CacheFactory.getAnyInstance().ge...
Create a Java method that does the following: "This method is called by the Cache Engine to execute the function.".
Of course, here is the Java code you requested: ```java @Override public final String render(final RenderConfiguration configuration, final Object entity) { // Check sanity if (configuration == null) { throw new IllegalArgumentException("Cannot handle null 'configuration' argument."); ...
Create a Java method that does the following: "Render an entity.".
Of course, here is the Java code you requested: ```java @Override public boolean accept(final Object entity) { return entity != null && acceptedType.isAssignableFrom(entity.getClass()); } ``` Hope this helps!
Create a Java method that does the following: "Checks if the entity is of the correct type.".
Of course, here is the Java code you requested: ```java public static boolean setProperty(Object target, String name, Object value) { try { for (PropertyDescriptor pd : Introspector.getBeanInfo(target.getClass()).getPropertyDescriptors()) { if (pd.getWriteMethod() != null && pd.getN...
Create a Java method that does the following: "Sets the value of a property on the object.".
Of course, here is the Java code you requested: ```java public static List<Method> getAnnotatedMethods(Class targetClass, Class<? extends Annotation> annotationType) { List<Method> annotatedMethods = new ArrayList<Method>(); for(Method method : targetClass.getDeclaredMethods()) { if(method...
Create a Java method that does the following: "Gets annotated methods of a class.".
Of course, here is the Java code you requested: ```java public static <T> T createObject(Class<T> clazz) { T object; try { object = clazz.newInstance(); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { ...
Create a Java method that does the following: "Create an instance of the class.".
Of course, here is the Java code you requested: ```java private String getConfigAttribute(Configuration config, ChainedItem<Configuration> parentConfiguration, String attributeName, String defaultValue) { String ret; try { ret = config.getAttribute(attr...
Create a Java method that does the following: "Get the value of an attribute from a configuration.".
Of course, here is the Java code you requested: ```java private String createReceivedAtKey(String fromClusterName, String toClusterName) { return KEY_PREFIX + fromClusterName + "-" + toClusterName + KEY_POSTFIX_DURATION; } ``` Hope this helps!
Create a Java method that does the following: "Create a received at key.".
Of course, here is the Java code you requested: ```java private void init() { try { debug("GuestNode#init(): Creating Cache"); ClientCacheFactory clientCacheFactory = new ClientCacheFactory(); Properties gemfireProperties = PropertiesHelper.filterProperties( System.getProperties(), GEMFIRE_PREFIX); ...
Create a Java method that does the following: "Initialize the cache.".
Of course, here is the Java code you requested: ```java private void waitForStarted() { debug("GuestNode#waitForStarted(): Waiting for other clusters started"); while (true) { boolean othersStarted = true; for (Object key : clustersProperties.keySet()) { String clusterName = (String) key; Long sta...
Create a Java method that does the following: "Waits until all other clusters have started.".
Of course, here is the Java code you requested: ```java private void waitForSent() { debug("GuestNode#waitForSent(): Waiting for other clusters sent"); while (true) { boolean othersSent = true; Map<String, Long> clusterNameToReceivedAtMap = new HashMap<String, Long>(); for (Object key : clustersProperti...
Create a Java method that does the following: "Waits for other clusters to be sent.".
Of course, here is the Java code you requested: ```java private void waitForConnected() { debug("GuestNode#waitForConnected(): Waiting for all the clusters connected"); while (true) { boolean connected = true; for (Object fromKey : clustersProperties.keySet()) { String fromClusterName = (String) fromKe...
Create a Java method that does the following: "Waits for all the clusters connected.".
Of course, here is the Java code you requested: ```java public void printState(boolean connected) { if (!quiet) { StringBuilder sb = new StringBuilder(); if (connected) { sb.append(localClusterName).append(" <= "); Iterator<Object> it = clustersProperties.keySet().iterator(); while (it.hasNext(...
Create a Java method that does the following: "Print the state of the cluster.".
Of course, here is the Java code you requested: ```java public static void main(String[] args) { try { if (args.length != 7) { Utils.exitWithFailure(); } String cluster = args[0]; Properties clustersProperties = PropertiesHelper .stringToProperties(args[1]); long timeout = Long.parseLong(args...
Create a Java method that does the following: "Main method to run the GuestNode class.".
Of course, here is the Java code you requested: ```java public void writePngImageAndImageMap(final RootDoc rootDoc, final String dotDiagram, final File outputDirectory, final String filename) thro...
Create a Java method that does the following: "Write the PNG image and ImageMap files to the output directory.".
Of course, here is the Java code you requested: ```java public short getVersionModelHashCode(int version) { List<XProperty> classFields = getOrderedProperties(); StringBuilder builder = new StringBuilder(); for (XProperty field : classFields) { if (version == -1 || version >= fie...
Create a Java method that does the following: "Get the version model hashCode.".