code
stringlengths
146
466k
prompt
stringlengths
54
1.5k
Of course, here is the Java code you requested: ```java @NotNull String firstPropertyIfNested(@NotNull String propertyName) { if (!isNestedProperty(propertyName)) { return propertyName; } return checkNotNull(propertyName.substring(0, propertyName.indexOf(SEPARATOR))); } ``` Hope this helps!
Create a Java method that does the following: "Returns the first property of a property name if it is nested.".
Of course, here is the Java code you requested: ```java public static @Nullable AssertionError comparisonFailure( @Nullable String message, @Nullable Object expected, @Nullable Object actual) { try { return newComparisonFailure(clean(message), expected, actual); } catch (Exception e) { return...
Create a Java method that does the following: "A method to check if two objects are equal.".
Of course, here is the Java code you requested: ```java public @NotNull ListAssert contains(@Nullable Object o, @NotNull Index index) { checkNotNull(index); isNotNull().isNotEmpty(); int indexValue = index.value(); int listSize = actualGroupSize(); if (indexValue < 0 || indexValue >= listSize) { ...
Create a Java method that does the following: "Check if the list contains the element at the given index.".
Of course, here is the Java code you requested: ```java public @NotNull ListAssert startsWith(@NotNull Object... sequence) { isNotNull(); checkNotNull(sequence); int sequenceSize = sequence.length; int listSize = actualGroupSize(); if (sequenceSize == 0 && listSize == 0) { return this; } ...
Create a Java method that does the following: "Check if the sequence starts with the actual.".
Of course, here is the Java code you requested: ```java @Override public @NotNull ListAssert onProperty(@NotNull String propertyName) { isNotNull(); if (actual.isEmpty()) { return new ListAssert(emptyList()); } return new ListAssert(PropertySupport.instance().propertyValues(propertyName, actual...
Create a Java method that does the following: "Override onProperty to check if the property is present in the actual list.".
Of course, here is the Java code you requested: ```java @Deprecated public @NotNull DoubleAssert isEqualTo(double expected, Delta delta) { return isEqualTo(expected, delta.value); } ``` Hope this helps!
Create a Java method that does the following: "Assert that two vectors are equal.".
Of course, here is the Java code you requested: ```java public @NotNull DoubleAssert isEqualTo(double expected, org.fest.assertions.Delta delta) { return isEqualTo(expected, delta.doubleValue()); } ``` Hope this helps!
Create a Java method that does the following: "Compares two double values.".
Of course, here is the Java code you requested: ```java public @NotNull DoubleAssert isLessThan(double other) { if (compareTo(other) < 0) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedGreaterThanOrEqualTo(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the two vectors are less than or equal to.".
Of course, here is the Java code you requested: ```java public @NotNull DoubleAssert isGreaterThanOrEqualTo(double other) { if (compareTo(other) >= 0) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedLessThan(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the two vectors are greater than or equal to.".
Of course, here is the Java code you requested: ```java public @NotNull DoubleAssert isLessThanOrEqualTo(double other) { if (compareTo(other) <= 0) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedGreaterThan(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the two vectors are less than or equal to.".
Of course, here is the Java code you requested: ```java public @NotNull LongAssert isGreaterThan(long other) { if (actual > other) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedLessThanOrEqualTo(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that two long values are greater than or equal to.".
Of course, here is the Java code you requested: ```java public @NotNull LongAssert isLessThan(long other) { if (actual < other) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedGreaterThanOrEqualTo(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the two long values are less than or equal to the given value.".
Of course, here is the Java code you requested: ```java public @NotNull LongAssert isGreaterThanOrEqualTo(long other) { if (actual >= other) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedLessThan(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the two long values are greater than or equal to the given value.".
Of course, here is the Java code you requested: ```java public @NotNull LongAssert isLessThanOrEqualTo(long other) { if (actual <= other) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedGreaterThan(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the two long values are less than or equal to the given value.".
Of course, here is the Java code you requested: ```java protected final void assertContains(@NotNull Object... objects) { isNotNull(); checkNotNull(objects); Collection<Object> notFound = notFoundInActual(objects); if (notFound.isEmpty()) { return; } throw failureIfExpectedElementsNotFoun...
Create a Java method that does the following: "Assert that the given objects are contained in the actual sequence.".
Of course, here is the Java code you requested: ```java protected final void assertContainsOnly(@NotNull Object... objects) { isNotNull(); checkNotNull(objects); Set<Object> copy = actualAsSet(); List<Object> notFound = notFoundInCopy(copy, newLinkedHashSet(objects)); if (!notFound.isEmpty()) { ...
Create a Java method that does the following: "Assert that the actual list contains only the given objects.".
Of course, here is the Java code you requested: ```java protected final void assertDoesNotHaveDuplicates() { isNotNull(); Collection<?> duplicates = duplicatesFrom(actualAsList()); if (duplicates.isEmpty()) { return; } failIfCustomMessageIsSet(); throw failure(format("<%s> contains duplic...
Create a Java method that does the following: "Asserts that the actual list does not contain duplicate elements.".
Of course, here is the Java code you requested: ```java public static @NotNull String format(@Nullable Description description, @NotNull String message) { checkNotNull(message); String s = valueOf(description); return format(s) + message; } ``` Hope this helps!
Create a Java method that does the following: "Format a CID message.".
Of course, here is the Java code you requested: ```java public static @NotNull IteratorAssert assertThat(@Nullable Iterable<?> actual) { Iterator<?> iterator = actual == null ? null : actual.iterator(); return assertThat(iterator); } ``` Hope this helps!
Create a Java method that does the following: "Assert that an iterable is an iterator.".
Of course, here is the Java code you requested: ```java public @NotNull CharAssert isUpperCase() { if (Character.isUpperCase(actual)) { return this; } failIfCustomMessageIsSet(); throw failure(String.format("<%s> should be an upper-case character", actual)); } ``` Hope this helps!
Create a Java method that does the following: "Assert that actual is uppercase.".
Of course, here is the Java code you requested: ```java protected static void failIfNotEqual(@Nullable String customErrorMessage, @Nullable Description descriptionOfActual, @Nullable Object actual, @Nullable Object expected) { if (areEqual(actual, expected)) { return; ...
Create a Java method that does the following: "Fails if two objects are not equal.".
Of course, here is the Java code you requested: ```java protected static @NotNull AssertionError comparisonFailed( @Nullable Description description, @Nullable Object actual, @Nullable Object expected) { AssertionError comparisonFailure = comparisonFailure(valueOf(description), expected, actual); if (com...
Create a Java method that does the following: "A method to check if two objects are equal.".
Of course, here is the Java code you requested: ```java protected static void failIfNotNull(@Nullable String customErrorMessage, @Nullable Description description, @Nullable Object o) { if (o == null) { return; } failWithMessage(customErrorMessage); fail(desc...
Create a Java method that does the following: "Fails if the object is null.".
Of course, here is the Java code you requested: ```java public @NotNull ObjectAssert isInstanceOf(@NotNull Class<?> type) { isNotNull(); checkNotNull(type); Class<?> current = actual.getClass(); if (type.isAssignableFrom(current)) { return this; } failIfCustomMessageIsSet(); throw fai...
Create a Java method that does the following: "Asserts that the actual object is an instance of the specified type.".
Of course, here is the Java code you requested: ```java public @NotNull ThrowableAssert hasMessage(@Nullable String message) { isNotNull(); failIfNotEqual(customErrorMessage(), rawDescription(), actual.getMessage(), message); return this; } ``` Hope this helps!
Create a Java method that does the following: "Fails if the exception has a message.".
Of course, here is the Java code you requested: ```java public @NotNull ThrowableAssert hasNoCause() { isNotNull(); Throwable actualCause = actual.getCause(); if (actualCause == null) { return this; } failIfCustomMessageIsSet(); throw failure(format("expected exception without cause, but ...
Create a Java method that does the following: "Fails if the exception has no cause.".
Of course, here is the Java code you requested: ```java @Override public @NotNull ThrowableAssert as(@Nullable Description description) { objectAssert.as(description); return super.as(description); } ``` Hope this helps!
Create a Java method that does the following: "Override as to allow for a description".
Of course, here is the Java code you requested: ```java public static @NotNull Entry entry(@Nullable Object key, @Nullable Object value) { return new Entry(key, value); } ``` Hope this helps!
Create a Java method that does the following: "Create a new entry.".
Of course, here is the Java code you requested: ```java public @NotNull MapAssert includes(@NotNull Entry... entries) { isNotNull(); checkNotNull(entries); List<Entry> notFound = newArrayList(); for (Entry e : entries) { if (!containsEntry(checkNotNull(e))) { notFound.add(e); } ...
Create a Java method that does the following: "Asserts that the map contains at least one of the given entries.".
Of course, here is the Java code you requested: ```java public @NotNull MapAssert excludes(@NotNull Entry... entries) { isNotNull(); checkNotNull(entries); List<Entry> found = newArrayList(); for (Entry e : entries) { if (containsEntry(checkNotNull(e))) { found.add(e); } } i...
Create a Java method that does the following: "Asserts that the given list of entries is excluded from the result.".
Of course, here is the Java code you requested: ```java public @NotNull ShortAssert isGreaterThan(short other) { if (actual > other) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedLessThanOrEqualTo(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that two short values are greater than or equal to.".
Of course, here is the Java code you requested: ```java public @NotNull ShortAssert isGreaterThanOrEqualTo(short other) { if (actual >= other) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedLessThan(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the short value is greater than or equal to the given value.".
Of course, here is the Java code you requested: ```java public @NotNull ShortAssert isLessThanOrEqualTo(short other) { if (actual <= other) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedGreaterThan(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the short value is less than or equal to the given value.".
Of course, here is the Java code you requested: ```java public final @NotNull S doesNotSatisfy(@NotNull Condition<A> condition) { if (!matches(condition)) { return myself(); } failIfCustomMessageIsSet(); throw failure(errorMessageIfConditionSatisfied(condition)); } ``` Hope this helps!
Create a Java method that does the following: "Checks if the condition is satisfied.".
Of course, here is the Java code you requested: ```java public final @NotNull S is(@NotNull Condition<A> condition) { if (matches(condition)) { return myself(); } failIfCustomMessageIsSet(); throw failure(errorMessageIfIsNot(condition)); } ``` Hope this helps!
Create a Java method that does the following: "Checks if the condition is satisfied.".
Of course, here is the Java code you requested: ```java public final @NotNull S isNot(@NotNull Condition<A> condition) { if (!matches(condition)) { return myself(); } failIfCustomMessageIsSet(); throw failure(errorMessageIfIs(condition)); } ``` Hope this helps!
Create a Java method that does the following: "Check if the condition is not.".
Of course, here is the Java code you requested: ```java public @NotNull S isEqualTo(@Nullable A expected) { failIfNotEqual(customErrorMessage(), rawDescription(), actual, expected); return myself(); } ``` Hope this helps!
Create a Java method that does the following: "Fails if the two terms are not equal.".
Of course, here is the Java code you requested: ```java public @NotNull S isNotEqualTo(@Nullable A other) { failIfEqual(customErrorMessage(), rawDescription(), actual, other); return myself(); } ``` Hope this helps!
Create a Java method that does the following: "Fails if the two terms are not equal.".
Of course, here is the Java code you requested: ```java public final @NotNull S isSameAs(@Nullable A expected) { failIfNotSame(customErrorMessage(), rawDescription(), actual, expected); return myself(); } ``` Hope this helps!
Create a Java method that does the following: "Fails if the two terms are not the same.".
Of course, here is the Java code you requested: ```java public final @NotNull S isNotSameAs(@Nullable A other) { failIfSame(customErrorMessage(), rawDescription(), actual, other); return myself(); } ``` Hope this helps!
Create a Java method that does the following: "Fails if two tokens are not the same.".
Of course, here is the Java code you requested: ```java public final @NotNull S isNotIn(@NotNull Collection<?> values) { checkNotNull(values); if (!isActualIn(values)) { return myself(); } failIfCustomMessageIsSet(); throw failure(unexpectedIn(actual, values)); } ``` Hope this helps!
Create a Java method that does the following: "Check if the subject is not in the given collection.".
Of course, here is the Java code you requested: ```java public @NotNull DoubleArrayAssert isEqualTo(@Nullable double[] expected, @NotNull Delta delta) { checkNotNull(delta); if (actual == expected) { return this; } if (actual == null || expected == null) { throw failureWhenNotEqual(expected...
Create a Java method that does the following: "Assert that two double arrays are equal.".
Of course, here is the Java code you requested: ```java @Override public @NotNull ObjectArrayAssert isNotEqualTo(@Nullable Object[] array) { if (!Arrays.deepEquals(actual, array)) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedEqual(actual, array)); } ``` Hope this help...
Create a Java method that does the following: "Fails if the actual object is not equal to the given array.".
Of course, here is the Java code you requested: ```java @Override public @NotNull ObjectArrayAssert onProperty(@NotNull String propertyName) { isNotNull(); if (actual.length == 0) { return new ObjectArrayAssert(new Object[0]); } List<Object> values = PropertySupport.instance().propertyValues(pr...
Create a Java method that does the following: "Override onProperty to check if the property is a valid CID .".
Of course, here is the Java code you requested: ```java protected final void description(@Nullable String d) { description(d == null ? null : new BasicDescription(d)); } ``` Hope this helps!
Create a Java method that does the following: "Sets the description of the phrase.".
Of course, here is the Java code you requested: ```java protected final @NotNull AssertionError failure(@NotNull String reason) { return Fail.failure(formattedErrorMessage(reason)); } ``` Hope this helps!
Create a Java method that does the following: "A helper method to create an AssertionError.".
Of course, here is the Java code you requested: ```java public @NotNull ByteAssert isGreaterThan(byte other) { // TODO check for NPE if (actual > other) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedLessThanOrEqualTo(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the two bytes are greater than or equal to the given value.".
Of course, here is the Java code you requested: ```java public @NotNull ByteAssert isGreaterThanOrEqualTo(byte other) { if (actual >= other) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedLessThan(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the target byte is greater than or equal to the given value.".
Of course, here is the Java code you requested: ```java @Override public @NotNull CollectionAssert onProperty(@NotNull String propertyName) { isNotNull(); checkNotNull(propertyName); if (actual.isEmpty()) { return new CollectionAssert(emptyList()); } return new CollectionAssert(PropertySupp...
Create a Java method that does the following: "Override onProperty to check if the property is a valid CRA - VISIT.".
Of course, here is the Java code you requested: ```java @Override public @NotNull IntArrayAssert isEqualTo(@Nullable int[] expected) { if (Arrays.equals(actual, expected)) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedNotEqual(actual, expected)); } ``` Hope this helps!
Create a Java method that does the following: "Assert that two int arrays are equal.".
Of course, here is the Java code you requested: ```java public @NotNull StringAssert isEqualToIgnoringCase(String expected) { if (actual == null && expected == null) { return this; } isNotNull(); if (actual.equalsIgnoreCase(expected)) { return this; } failIfCustomMessageIsSet(); ...
Create a Java method that does the following: "Assert that two strings are equal ignoring case.".
Of course, here is the Java code you requested: ```java public @NotNull StringAssert excludes(String s) { isNotNull(); if (actual.indexOf(s) == -1) { return this; } failIfCustomMessageIsSet(); throw failure(format("<%s> should not contain the String:<%s>", actual, s)); } ``` Hope this help...
Create a Java method that does the following: "Fails if the String is not contained in the String.".
Of course, here is the Java code you requested: ```java public @NotNull StringAssert containsIgnoringCase(@NotNull String text) { checkNotNull(text); isNotNull(); if (actual.toLowerCase().contains(text.toLowerCase())) { return this; } failIfCustomMessageIsSet(); throw failure(format("<%s>...
Create a Java method that does the following: "Fails if the string does not contain the given text ignoring case.".
Of course, here is the Java code you requested: ```java public @NotNull FloatAssert isEqualTo(float expected, @NotNull org.fest.assertions.Delta delta) { return isEqualTo(expected, delta.floatValue()); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the given float value is equal to the given delta.".
Of course, here is the Java code you requested: ```java public @NotNull FloatAssert isGreaterThan(float other) { if (compareTo(other) > 0) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedLessThanOrEqualTo(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the two float values are greater than or equal to the other.".
Of course, here is the Java code you requested: ```java public static @NotNull List<Object> copyToList(@NotNull Object array) { return copy(checkNotNull(array), newArrayList()); } ``` Hope this helps!
Create a Java method that does the following: "Copy to list.".
Of course, here is the Java code you requested: ```java public static int sizeOf(@NotNull Object array) { checkNotNull(array); validateIsArray(array); return getLength(array); } ``` Hope this helps!
Create a Java method that does the following: "Get size of an array.".
Of course, here is the Java code you requested: ```java public @NotNull IntAssert isLessThanOrEqualTo(int other) { if (actual <= other) { return this; } failIfCustomMessageIsSet(); throw failure(unexpectedGreaterThan(actual, other)); } ``` Hope this helps!
Create a Java method that does the following: "Asserts that the actual value is less than or equal to the given value.".
Of course, here is the Java code you requested: ```java public View getDropDownView(int index, View convertView, ViewGroup parent) { return dropDownViewFactory.getView(convertView, itemList.get(index)); } ``` Hope this helps!
Create a Java method that does the following: "Get the DropDownView for the item at the given index.".
Of course, here is the Java code you requested: ```java @Override public T fromOrdinal(int ordinal) { checkStatus(Status.INITIALIZED); if(ordinal<0 || this.ordinal<ordinal) { throw new IndexOutOfBoundsException("No term available with ordinal '"+ordinal+"'"); } return this.terms.get(ordinal); } ``` Hope ...
Create a Java method that does the following: "Returns the term with the given ordinal.".
Of course, here is the Java code you requested: ```java @Override public final Iterator<Term> iterator() { checkStatus(Status.INITIALIZED); final Iterator<? extends Term> iterator = this.terms.values().iterator(); return new Iterator<Term>() { @Override public boolean hasNext() { return iterator.hasNe...
Create a Java method that does the following: "Returns an iterator over the terms in this term set.".
Of course, here is the Java code you requested: ```java protected final <S extends ImmutableTerm> void registerTerm(S term) { checkStatus(Status.INITIALIZING); checkInitializationPrecondition(this.nameOrdinal.containsKey(term.name()),"Term '%s' has not been reserved",term.name()); checkInitializationPrecondition...
Create a Java method that does the following: "Registers a term with the registry.".
Of course, here is the Java code you requested: ```java protected final void initialize() { checkStatus(Status.INITIALIZING); if(this.terms.size()!=this.nameOrdinal.size()) { throw new IllegalStateException( String.format( "Vocabulary '%s' (%s) initialization failure: not all reserved names have been r...
Create a Java method that does the following: "Initializes the vocabulary.".
Of course, here is the Java code you requested: ```java @Override public Resource attach(String attachmentId, ResourceId resourceId) { return attach(attachmentId,resourceId,Resource.class); } ``` Hope this helps!
Create a Java method that does the following: "Override attach to allow attachment to be set to a resource".
Of course, here is the Java code you requested: ```java @Override public void modify(EntityTag newEntityTag, Date newLastModified) { checkState(this.deleted==null,"Endpoint is already deleted"); this.entityTag=newEntityTag; this.lastModified=new Date(newLastModified.getTime()); } ``` Hope this helps!
Create a Java method that does the following: "Modify the entity tag and last modified fields of this endpoint.".
Of course, here is the Java code you requested: ```java private void registerConstraintReport(Resource resource, InvalidContentException error) { ConstraintReport report= resource. addConstraintReport( error.getConstraints(), new Date(), currentRequest()); this.constraintReportRepository.add(...
Create a Java method that does the following: "Registers a constraint report for the given error.".
Of course, here is the Java code you requested: ```java @Override public ApplicationContextOperation createOperation(HttpRequest request) { checkNotNull(request,"Http request cannot be null"); DefaultApplicationOperation operation=this.currentOperation.get(); checkState(operation==null,"An operation is ongoing ...
Create a Java method that does the following: "Creates an application context operation.".
Of course, here is the Java code you requested: ```java @Override public void registerApplicationLifecycleListener(ApplicationLifecycleListener listener) { checkNotNull(listener,APPLICATION_LIFECYCLE_LISTENER_CANNOT_BE_NULL); this.engine().applicationLifecycleService().registerApplicationLifecycleListener(listene...
Create a Java method that does the following: "Register application lifecycle listener.".
Of course, here is the Java code you requested: ```java @Override public void deregisterApplicationLifecycleListener(ApplicationLifecycleListener listener) { checkNotNull(listener,APPLICATION_LIFECYCLE_LISTENER_CANNOT_BE_NULL); this.engine().applicationLifecycleService().deregisterApplicationLifecycleListener(lis...
Create a Java method that does the following: "Deregister an application lifecycle listener.".
Of course, here is the Java code you requested: ```java @Override public E fromString(final String rawValue) { try { return Enum.valueOf(this.targetClass, rawValue); } catch (Exception e) { throw new ObjectParseException(e,targetClass(),rawValue); } } ``` Hope this helps!
Create a Java method that does the following: "Converts a string to an enum value.".
Of course, here is the Java code you requested: ```java @Override public void update(ResourceSnapshot resource, DataSet content, WriteSession session) throws InconsistentContentException, UnknownResourceException { DataSet dataSet = get(resource); logDebug(resource, "Enforcing consistency..."); enforceConsisten...
Create a Java method that does the following: "Update the data set of the specified resource.".
Of course, here is the Java code you requested: ```java public static RuntimeDelegate getInstance() { RuntimeDelegate result = RuntimeDelegate.CACHED_DELEGATE.get(); if (result != null) { return result; } synchronized(RuntimeDelegate.CACHED_DELEGATE) { result=RuntimeDelegate.CACHED_DELEGATE.get(); if(...
Create a Java method that does the following: "Get the singleton instance of the class.".
Of course, here is the Java code you requested: ```java public static void setInstance(final RuntimeDelegate delegate) { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(suppressAccessChecksPermission); } RuntimeDelegate.CACHED_DELEGATE.set(delegate); ...
Create a Java method that does the following: "Set the instance of the runtime delegate.".
Of course, here is the Java code you requested: ```java private static URIRef relativeResolution(URI target, URI base) { URIRef Base=URIRef.create(base); // NOSONAR URIRef R=URIRef.create(target); // NOSONAR URIRef T=URIRef.create(); // NOSONAR if(defined(R.scheme)) { T.scheme = R.scheme; T.authority ...
Create a Java method that does the following: "This method is used to perform a relative resolution of a URI.".
Of course, here is the Java code you requested: ```java private static String merge(String path, String relativePath, boolean hasAuthority) { String parent=path; if(hasAuthority && parent.isEmpty()) { parent=SLASH; } return parent.substring(0,parent.lastIndexOf('/')+1).concat(relativePath); } ``` Hope thi...
Create a Java method that does the following: "Merge a path with a relative path.".
Of course, here is the Java code you requested: ```java @Override public Resource resourceOfId(ResourceId id) { lock.readLock().lock(); try { return resources.get(id); } finally { lock.readLock().unlock(); } } ``` Hope this helps!
Create a Java method that does the following: "Returns the resource with the given id.".
Of course, here is the Java code you requested: ```java @Override public Container containerOfId(ResourceId id) { lock.readLock().lock(); try { return containers.get(id); } finally { lock.readLock().unlock(); } } ``` Hope this helps!
Create a Java method that does the following: "Returns the container with the given id.".
Of course, here is the Java code you requested: ```java @Override public void remove(Resource resource) { checkNotNull(resource,"Resource cannot be null"); lock.writeLock().lock(); try { resources.remove(resource.id()); containers.remove(resource.id()); } finally { lock.writeLock().unlock(); } } `...
Create a Java method that does the following: "Removes the specified resource from the list of resources.".
Of course, here is the Java code you requested: ```java @Override public void shutdown() throws LifecycleException { lock.writeLock().lock(); try { resources.clear(); containers.clear(); } finally { lock.writeLock().unlock(); } } ``` Hope this helps!
Create a Java method that does the following: "Shutdown the managed resources.".
Of course, here is the Java code you requested: ```java Attachability attachability(String attachmentId, Name<?> name) { // NOSONAR Attachability result=null; if(this.attachmentsById.containsKey(attachmentId)) { result=Attachability.ID_ALREADY_USED; } else { result=Attachability.ATTACHABLE; } return re...
Create a Java method that does the following: "This method is used to determine the attachability of an attachment.".
Of course, here is the Java code you requested: ```java @Override public ResourceTemplate findById(String templateId) { return ImmutableTemplateFactory.newImmutable(delegate().findById(templateId)); } ``` Hope this helps!
Create a Java method that does the following: "Returns an immutable copy of the template with the given id.".
Of course, here is the Java code you requested: ```java @Override public Parameter getParameter(String paramName) { checkNotNull(paramName,"Parameter name cannot be null"); return this.parameters.get(paramName); } ``` Hope this helps!
Create a Java method that does the following: "Gets the parameter with the given name.".
Of course, here is the Java code you requested: ```java public Name<String> name(Class<?> clazz, String... names) { return name(clazz.getCanonicalName(), names); } ``` Hope this helps!
Create a Java method that does the following: "Returns a name for the given class.".
Of course, here is the Java code you requested: ```java @Override public <S extends ResourceSnapshot> S find( Class<? extends S> snapshotClass, Name<?> name, Class<? extends ResourceHandler> handlerClass) { checkNotNull(snapshotClass,"Resource snapshot class cannot be null"); checkNotNull(name,RESOURCE_N...
Create a Java method that does the following: "Find a snapshot of a resource managed by a container.".
Of course, here is the Java code you requested: ```java @Override public <S extends ResourceSnapshot> S resolve( final Class<? extends S> snapshotClass, final Individual<?,?> individual) { checkNotNull(snapshotClass,"Resource snapshot class cannot be null"); checkNotNull(individual,"Individual cannot be nul...
Create a Java method that does the following: "Resolves the given individual snapshot to the given snapshot class.".
Of course, here is the Java code you requested: ```java @Override public void modify(ResourceSnapshot resource) { checkNotNull(resource,RESOURCE_CANNOT_BE_NULL); checkArgument(resource instanceof DelegatedResourceSnapshot,"Unknown resource '%s'",resource.name()); checkState(this.status.equals(Status.ACTIVE),WRI...
Create a Java method that does the following: "Modify the resource snapshot.".
Of course, here is the Java code you requested: ```java @Override public void saveChanges() throws WriteSessionException { checkState(this.status.equals(Status.ACTIVE),WRITE_SESSION_NOT_ACTIVE,this.status); this.status=Status.COMPLETED; for(Entry<ResourceId, DelegatedResourceSnapshot> entry:this.resourceCache.e...
Create a Java method that does the following: "Saves all changes in the cache.".
Of course, here is the Java code you requested: ```java @SuppressWarnings("unchecked") @Override protected <T extends Serializable> Name<T> assemble(Serializable subject) throws IOException { return (Name<T>)subject; } ``` Hope this helps!
Create a Java method that does the following: "Assemble a name from a serializable object.".
Of course, here is the Java code you requested: ```java public static void preferredSyntax(MediaRangeSyntax syntax) { if(syntax==null) { SYNTAX.set(MediaRangeSyntax.RFC7230); } else { SYNTAX.set(syntax); } } ``` Hope this helps!
Create a Java method that does the following: "Sets the preferred syntax for the media range.".
Of course, here is the Java code you requested: ```java public static MediaType wildcard(String type) { requireNonNull(type,TYPE_CANNOT_BE_NULL); return new ImmutableMediaType(MediaTypes.preferredSyntax(),type,WILDCARD_TYPE,null,null); } ``` Hope this helps!
Create a Java method that does the following: "Returns an immutable wildcard media type.".
Of course, here is the Java code you requested: ```java public static MediaType wildcard(String type, String suffix) { requireNonNull(type,TYPE_CANNOT_BE_NULL); requireNonNull(suffix,"Suffix cannot be null"); return new ImmutableMediaType(MediaTypes.preferredSyntax(),type,WILDCARD_TYPE,suffix,null); } ``` Hope...
Create a Java method that does the following: "Creates a wildcard media type with the given type and suffix.".
Of course, here is the Java code you requested: ```java public static boolean isWildcardSubType(final MediaType mediaType) { requireNonNull(mediaType,MEDIA_TYPE_CANNOT_BE_NULL); return WILDCARD_TYPE.equals(mediaType.subType()); } ``` Hope this helps!
Create a Java method that does the following: "Checks if the given media type is a wildcard subtype.".
Of course, here is the Java code you requested: ```java public static String toHeader(final MediaType mediaType) { requireNonNull(mediaType,REFERENCE_MEDIA_TYPE_CANNOT_BE_NULL); final StringBuilder builder= new StringBuilder(). append(mediaType.type().toLowerCase(Locale.ENGLISH)). append('/'). appen...
Create a Java method that does the following: "Converts a MediaType to a header string.".
Of course, here is the Java code you requested: ```java @Override public Resource createResource(ResourceTemplate template, Name<?> name) { checkNotNull(name,"Resource name cannot be null"); checkArgument(this.templateLibrary.contains(template),"Unknown template "+template); RootResourceCreator creator= new ...
Create a Java method that does the following: "Create a new resource from a template.".
Of course, here is the Java code you requested: ```java @Override public void run() { ApplicationContext ctx = ApplicationContext.getInstance(); LOGGER.debug("Starting resolution process on {}...",new Date()); try(WriteSession session=ctx.createSession()) { ResourceSnapshot snapshot= session.find( R...
Create a Java method that does the following: "This method is called by the application to perform the resolution process.".
Of course, here is the Java code you requested: ```java @Override public <V> V as(Class<? extends V> valueClass) { try { return TypeAdapter.adapt(this, valueClass); } catch (CannotAdaptClassesException e) { throw new UnsupportedOperationException("Class '"+getClass().getCanonicalName()+" cannot be transform...
Create a Java method that does the following: "Returns the value of this object as the given class.".
Of course, here is the Java code you requested: ```java @Override public int compareTo(Term other) { ImmutableTerm self = this; if(self.getDeclaringVocabulary() != other.getDeclaringVocabulary()) { throw new ClassCastException(); } return self.ordinal - other.ordinal(); } ``` Hope this helps!
Create a Java method that does the following: "Compares two terms.".
Of course, here is the Java code you requested: ```java @Override public ResourceSnapshot create(ContainerSnapshot container, DataSet representation, WriteSession session) { NameProvider nameProvider = nameProvider(container.name()); Name<?> nextName = nameProvider.nextMemberName(); try { bookHandler().add(n...
Create a Java method that does the following: "Create a new member.".
Of course, here is the Java code you requested: ```java @Override public void add(ConstraintReport report) { checkNotNull(report,"Constraint report cannot be null"); this.lock.writeLock().lock(); try { ConstraintReportId id = report.id(); this.failureIds.put(id.resourceId(),id.failureId()); this.report...
Create a Java method that does the following: "Adds a constraint report to the constraint report list.".
Of course, here is the Java code you requested: ```java @Override public void remove(ConstraintReport report) { checkNotNull(report,"Constraint report cannot be null"); this.lock.writeLock().lock(); try { ConstraintReportId reportId = report.id(); this.failureIds.remove(reportId.resourceId(),reportId.fail...
Create a Java method that does the following: "Removes the specified constraint report from this constraint report repository.".