code stringlengths 146 466k | prompt stringlengths 54 1.5k |
|---|---|
Of course, here is the Java code you requested:
```java
@Nullable
public static Drawable tint(Context context, @DrawableRes int drawableId, @AttrRes int attrId) {
Drawable d = context.getDrawable(drawableId);
if (d != null) {
d.setTint(Themes.getColor(context, attrId));
}
... | Create a Java method that does the following: "Tint the image of a specific drawable.". |
Of course, here is the Java code you requested:
```java
@Nullable
public static Drawable matchText(Context context, @DrawableRes int drawableId, TextView text) {
Drawable d = context.getDrawable(drawableId);
if (d != null) {
int size = Math.round(text.getTextSize());
d.setBo... | Create a Java method that does the following: "Retrieve a drawable from a TextView.". |
Of course, here is the Java code you requested:
```java
public static ShapeDrawable oval(@ColorInt int color) {
if (sOval == null) {
sOval = new OvalShape();
}
ShapeDrawable d = new ShapeDrawable(sOval);
d.setIntrinsicWidth(-1);
d.setIntrinsicHeight(-1);
d.ge... | Create a Java method that does the following: "Create an oval shape drawable.". |
Of course, here is the Java code you requested:
```java
public static Rect getFrame(Activity a) {
Rect frame = new Rect();
a.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
return frame;
}
```
Hope this helps! | Create a Java method that does the following: "Get the frame of the activity which is used to display the activity s log messages.". |
Of course, here is the Java code you requested:
```java
public static Looper mineOrMain() {
Looper looper = Looper.myLooper();
return looper != null ? looper : Looper.getMainLooper();
}
```
Hope this helps! | Create a Java method that does the following: "Get the main or mine Looper.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
public static <E> List<E> values(SparseArray<E> array) {
return (List<E>) values(array, null, null, null, null);
}
```
Hope this helps! | Create a Java method that does the following: "Returns a list of the elements in the given sparse array.". |
Of course, here is the Java code you requested:
```java
private void checkAdapter() {
PagerAdapter adapter = mPager.getAdapter();
if (mAdapter != adapter) {
if (mAdapter != null) {
mAdapter.unregisterDataSetObserver(mObserver);
}
mAdapter = adapter;
... | Create a Java method that does the following: "Check adapter.". |
Of course, here is the Java code you requested:
```java
private void checkDrawable() {
Drawable drawable = mView.getDrawable();
if (mDrawable != drawable) {
/* get the latest View size and ensure that it's been measured */
mViewWidth = mView.getWidth();
mViewHeight =... | Create a Java method that does the following: "checkDrawable is called to check if the Drawable is the same as the current one.". |
Of course, here is the Java code you requested:
```java
private void updateMatrix(int position, float offset) {
if (mDrawable != null && mScale > 0.0f) {
if (mPageCount == -1 && mAdapter != null) { // cache page count and translation values
mPageCount = mAdapter.getCount();
... | Create a Java method that does the following: "Update the matrix.". |
Of course, here is the Java code you requested:
```java
private int updDel(int op, Uri uri, ContentValues vals, String sel, String[] args) {
/* get the IDs of records that will be affected */
Sql sql = elements(op, uri, new String[]{"rowid"}, sel, args, null);
long[] ids = Cursors.allLongs(sql.... | Create a Java method that does the following: "Update or delete a single record in the database.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("ConstantConditions")
private void notifyChange(Uri notify, Uri orig) {
if (orig.getBooleanQueryParameter(NOTIFY_CHANGE, true)) {
getContext().getContentResolver().notifyChange(notify, null,
!orig.getB... | Create a Java method that does the following: "Notify the content resolver of a change.". |
Of course, here is the Java code you requested:
```java
private Sql elements(int op, Uri uri, String[] proj, String sel, String[] args, String order) {
MutableSql sql = translate(uri);
if (sql == null) {
sql = Sql.create();
}
if (sql.table() == null) {
sql.table(... | Create a Java method that does the following: "Get the elements from the database.". |
Of course, here is the Java code you requested:
```java
public static int getByteCount(int width, int height, Config config) {
int bytes = 0;
switch (config) {
case ALPHA_8:
bytes = 1;
break;
case RGB_565:
bytes = 2;
... | Create a Java method that does the following: "Gets the byte count of a image in bytes.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("ConstantConditions")
public void setContentView(@LayoutRes int layoutId, @IdRes int pagerId, @IdRes int pane1Id,
@IdRes int pane2Id) {
setContentView(layoutId);
Fragment pane1 = findFragmentByP... | Create a Java method that does the following: "This method sets the content view of the image.". |
Of course, here is the Java code you requested:
```java
protected void setSummary(Preference pref) {
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
if (pref instanceof RingtonePreference) {
String val = prefs.getString(pref.getKey(), null);
if (!TextUti... | Create a Java method that does the following: "Set the summary of the given preferences.". |
Of course, here is the Java code you requested:
```java
public static Bundle of(String key, long value) {
Bundle b = new Bundle(1);
b.putLong(key, value);
return b;
}
```
Hope this helps! | Create a Java method that does the following: "Create a Bundle with a String key and long value.". |
Of course, here is the Java code you requested:
```java
public static Intent newIntent(Context context, String action, Uri data, ContentValues values) {
return newIntent(context, action, data, values, null, null);
}
```
Hope this helps! | Create a Java method that does the following: "Create an intent to execute the specified action on the specified context.". |
Of course, here is the Java code you requested:
```java
public static Intent newDeleteIntent(Context context, Uri data) {
return newIntent(context, ACTION_DELETE, data, null, null, null);
}
```
Hope this helps! | Create a Java method that does the following: "Create an intent to delete a resource from the cache.". |
Of course, here is the Java code you requested:
```java
public static Intent newDeleteIntent(Context context, Uri data, String selection,
String[] selectionArgs) {
return newIntent(context, ACTION_DELETE, data, null, selection, selectionArgs);
}
```
Hope this helps... | Create a Java method that does the following: "Create an intent to delete a record from the database.". |
Of course, here is the Java code you requested:
```java
public static int getColor(Context context, @AttrRes int attrId) {
int color = 0;
TypedArray a = context.obtainStyledAttributes(new int[]{attrId});
try {
color = a.getColor(0, 0);
} catch (UnsupportedOperationException ... | Create a Java method that does the following: "Get the color of a single attribute.". |
Of course, here is the Java code you requested:
```java
@Nullable
public static Drawable getActionBarBackground(Context context) {
int[] attrs = {android.R.attr.actionBarStyle};
TypedArray a = context.obtainStyledAttributes(attrs);
int id = a.getResourceId(0, 0);
a.recycle();
... | Create a Java method that does the following: "Get the action bar background drawable.". |
Of course, here is the Java code you requested:
```java
public static boolean isConnected(Context context) {
NetworkInfo info = Managers.connectivity(context).getActiveNetworkInfo();
return info != null && info.isConnected();
}
```
Hope this helps! | Create a Java method that does the following: "Check if the context is connected to a network.". |
Of course, here is the Java code you requested:
```java
public void diff_cleanupSemantic(LinkedList<Diff> diffs) {
if (diffs.isEmpty()) {
return;
}
boolean changes = false;
Stack<Diff> equalities = new Stack<Diff>(); // Stack of qualities.
String lastequality = null; // Always equal to equal... | Create a Java method that does the following: "This method is used to cleanup the semantic structure of the diffs.". |
Of course, here is the Java code you requested:
```java
public void diff_cleanupSemanticLossless(LinkedList<Diff> diffs) {
String equality1, edit, equality2;
String commonString;
int commonOffset;
int score, bestScore;
String bestEquality1, bestEdit, bestEquality2;
// Create a new iterator at t... | Create a Java method that does the following: "This method is used to cleanup semantic errors.". |
Of course, here is the Java code you requested:
```java
private int diff_cleanupSemanticScore(String one, String two) {
if (one.length() == 0 || two.length() == 0) {
// Edges are the best.
return 6;
}
// Each port of this function behaves slightly differently due to
// subtle differences i... | Create a Java method that does the following: "This function is used to cleanup the semantic score of two strings.". |
Of course, here is the Java code you requested:
```java
public LinkedList<Patch> patch_make(String text1, LinkedList<Diff> diffs) {
if (text1 == null || diffs == null) {
throw new IllegalArgumentException("Null inputs. (patch_make)");
}
LinkedList<Patch> patches = new LinkedList<Patch>();
if (di... | Create a Java method that does the following: "Create a list of patches for a single document.". |
Of course, here is the Java code you requested:
```java
public List<Patch> patch_fromText(String textline)
throws IllegalArgumentException {
List<Patch> patches = new LinkedList<Patch>();
if (textline.length() == 0) {
return patches;
}
List<String> textList = Arrays.asList(textline.split("\... | Create a Java method that does the following: "Get the patches from a text string.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
public <T> Either<T, R> map(Function<L, T> function) {
return either.isLeft() ? Left(function.apply(get())) : (Either<T, R>) either;
}
```
Hope this helps! | Create a Java method that does the following: "Maps this Either to a new instance of the type specified by the given function.". |
Of course, here is the Java code you requested:
```java
@Override
public boolean tryComplete(Try<T> result) {
Validator.requireNonNull(result, "Must provide a valid result");
return tryComplete(future -> future.complete(result));
}
```
Hope this helps! | Create a Java method that does the following: "Try to complete the result.". |
Of course, here is the Java code you requested:
```java
@Override
public boolean tryCompleteWith(Future<T> result) {
return tryComplete(future -> result.onComplete(response -> future.complete(response)));
}
```
Hope this helps! | Create a Java method that does the following: "Try to complete the result with the result future.". |
Of course, here is the Java code you requested:
```java
private boolean tryComplete(Consumer<FutureImpl<T>> c) {
if (completed.compareAndSet(false, true)) {
//This Try is only here to manage any unforeseen exception raised by the Future event listener
//See issue#41
Try(() -> c.ac... | Create a Java method that does the following: "Try to complete the task.". |
Of course, here is the Java code you requested:
```java
public static <T> T requireNonNull(T obj, String message) {
if (obj == null) {
throw new IllegalArgumentException(message);
}
return obj;
}
```
Hope this helps! | Create a Java method that does the following: "Null - safe method to check that the passed in object is not null.". |
Of course, here is the Java code you requested:
```java
@Override
public <R> Either<T, R> toLeft(Supplier<R> right) {
return Right(right.get());
}
```
Hope this helps! | Create a Java method that does the following: "Override toLeft to return right value.". |
Of course, here is the Java code you requested:
```java
@Override
public <L> Either<L, T> toRight(Supplier<L> left) {
return Left(left.get());
}
```
Hope this helps! | Create a Java method that does the following: "Override toRight to allow for a supplier to be used as a left value.". |
Of course, here is the Java code you requested:
```java
public static Future<Unit> Future(VoidFunction0 function, Executor executor) {
return Future(() -> {
function.apply();
return Unit.Instance;
}, executor);
}
```
Hope this helps! | Create a Java method that does the following: "A Future that is a blocking call that will be completed with the given function.". |
Of course, here is the Java code you requested:
```java
public static <T> Future<T> Future(ThrowableFunction0<T> function) {
return Future.apply(function);
}
```
Hope this helps! | Create a Java method that does the following: "Create a Future that is a result of applying the given ThrowableFunction0 to the result.". |
Of course, here is the Java code you requested:
```java
public static <T> Future<T> Future(ThrowableFunction0<T> function, Executor executor) {
return Future.apply(function, executor);
}
```
Hope this helps! | Create a Java method that does the following: "Create a new Future that is created by applying the given ThrowableFunction0 to the given Executor.". |
Of course, here is the Java code you requested:
```java
public static <T> Future<T> Future(java.util.concurrent.Future<T> future) {
return Future.apply(() -> future.get());
}
```
Hope this helps! | Create a Java method that does the following: "Returns a new thread - safe future that is returned by the given future.". |
Of course, here is the Java code you requested:
```java
public static Executor createCachedThreadPoolExecutor(ThreadFactory threadFactory) {
return create(java.util.concurrent.Executors.newCachedThreadPool(threadFactory));
}
```
Hope this helps! | Create a Java method that does the following: "Create a thread pool executor that uses the specified thread factory.". |
Of course, here is the Java code you requested:
```java
@Override
public void onSuccess(Consumer<T> consumer) {
Validator.requireNonNull(consumer, "Null is not a valid consumer");
// register a complete handler and ignore any Failure responses
onComplete(result -> {
// should it... | Create a Java method that does the following: "Callback method for the result of a SequenceSet request.". |
Of course, here is the Java code you requested:
```java
@Override
public void onComplete(Consumer<Try<T>> c) {
Validator.requireNonNull(c, "Null is not a valid consumer");
eventHandlers.add(new EventHandler(c));
// invoke all new handlers in case this Future is already completed
not... | Create a Java method that does the following: "Called when the Future completes.". |
Of course, here is the Java code you requested:
```java
@Override
public Future<T> filter(Predicate<T> predicate) {
Validator.requireNonNull(predicate, "Null is not a valid predicate");
// Create new future expected to hold the value of the mapped type
FutureImpl<T> future = new FutureImpl<... | Create a Java method that does the following: "Filter the result of the request using the predicate.". |
Of course, here is the Java code you requested:
```java
@Override
public Future<T> recover(ThrowableFunction1<Throwable, T> recoverFunction) {
Validator.requireNonNull(recoverFunction, "Null is not a valid function");
// Create new future expected to hold the value of the mapped type
Future... | Create a Java method that does the following: "Creates a future that will be completed with the value of the mapped type containing the result of the request.". |
Of course, here is the Java code you requested:
```java
@Override
public <R> Option<R> map(ThrowableFunction1<T, R> f) {
return flatMap(v -> Option.apply(f.apply(v)));
}
```
Hope this helps! | Create a Java method that does the following: "Map the exception to an exception type.". |
Of course, here is the Java code you requested:
```java
@Override
public <L> Either<L, T> toRight(Supplier<L> left) {
return Right(value);
}
```
Hope this helps! | Create a Java method that does the following: "Converts the value of the token to an right token.". |
Of course, here is the Java code you requested:
```java
@Override
public Thread newThread(Runnable runnable) {
return new Thread(runnable, threadName + "-" + counter.getAndIncrement());
}
```
Hope this helps! | Create a Java method that does the following: "Creates a new thread with the specified runnable.". |
Of course, here is the Java code you requested:
```java
public Option<Either<L, R>> filter(Predicate<R> predicate) {
return Option.apply(exists(predicate) ? either : null);
}
```
Hope this helps! | Create a Java method that does the following: "Returns the first element that matches the given predicate or null if none.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
@Override
public <R> Try<R> map(ThrowableFunction1<T, R> function) {
return (Try<R>) this;
}
```
Hope this helps! | Create a Java method that does the following: "Maps a Throwable to a Try.". |
Of course, here is the Java code you requested:
```java
@Override
public Try<T> recoverWith(ThrowableFunction1<Throwable, Try<T>> function) {
try {
return function.apply(throwable);
}
catch(Throwable t) {
return new Failure<>(t);
}
}
```
Hope this helps! | Create a Java method that does the following: "Override this method to recover from a Throwable.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
static <T> Try<T> newInstance(String className) {
return Try(() -> (T) Class.forName(className).newInstance());
}
```
Hope this helps! | Create a Java method that does the following: "Create a new instance of the class with the specified name.". |
Of course, here is the Java code you requested:
```java
@Override
public <T> Future<T> execute(final Callable<T> callable) {
final Promise<T> promise = Promise();
return execute(promise, () -> {
try {
promise.success(callable.call());
} catch (Exception ex) {... | Create a Java method that does the following: "Execute a Callable in a thread pool.". |
Of course, here is the Java code you requested:
```java
@Override
public <T> List<Future<T>> executeAll(@SuppressWarnings("unchecked") Callable<T>... callables) {
List<Future<T>> responses = new ArrayList<>();
for (Callable<T> callable : callables) {
responses.add(execute(callable));
... | Create a Java method that does the following: "Execute all the Callable in the order of the result.". |
Of course, here is the Java code you requested:
```java
private <T> Future<T> execute(Promise<T> promise, Runnable runnable) {
try {
executor.execute(runnable);
} catch (RejectedExecutionException ex) {
// could be rejected due to resource starvation, report a failure
... | Create a Java method that does the following: "Execute the runnable and return a future that is returned.". |
Of course, here is the Java code you requested:
```java
@Override
public <R> Try<R> map(ThrowableFunction1<T, R> function) {
return Try(() -> function.apply(value));
}
```
Hope this helps! | Create a Java method that does the following: "Maps the exception to a try.". |
Of course, here is the Java code you requested:
```java
@Override
public Try<T> filter(Predicate<T> predicate) {
return predicate.test(value) ? this : new Failure<>(new NoSuchElementException("Predicate did not match value, now empty result"));
}
```
Hope this helps! | Create a Java method that does the following: "Filter the Try.". |
Of course, here is the Java code you requested:
```java
@Override
public <T> T fold(Function<L, T> func_left, Function<R, T> func_right) {
return func_right.apply(value);
}
```
Hope this helps! | Create a Java method that does the following: "Folds the two sets of tokens into a single value.". |
Of course, here is the Java code you requested:
```java
String convertSoapMessageAsString(SOAPMessage soapMessage) {
if (soapMessage == null) {
return "null";
}
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
soapMessage.writeTo(os);
return new String(os.toByteArray(), determineMessageE... | Create a Java method that does the following: "Convert a SOAP message to a string.". |
Of course, here is the Java code you requested:
```java
public boolean shouldBeProcessed(final ProfileSettings profileSettings) {
if (profileSettings != null) {
String propertyName = GetterUtilities.getFullQualifiedFieldName(baseType, method);
Boolean shouldBeProcessed = profileSettin... | Create a Java method that does the following: "Returns true if the record should be processed.". |
Of course, here is the Java code you requested:
```java
protected boolean hasTraceeContextProviderAnnotation(final Object instance) {
if (instance == null) {
return false;
}
TraceeContextProvider annotation = TraceeContextLogAnnotationUtilities.getAnnotationFromType(instance);
... | Create a Java method that does the following: "Check if the given object has a TraceeContextProvider annotation.". |
Of course, here is the Java code you requested:
```java
protected static synchronized FileObjectWrapper getOrCreateProfileProperties(final Filer filer, String fileName) throws IOException {
FileObjectWrapper fileObject = traceeProfileProperties.get(fileName);
if (fileObject == null) {
fileObject = new FileOb... | Create a Java method that does the following: "Gets or creates the tracee profile properties.". |
Of course, here is the Java code you requested:
```java
protected boolean isParentAnnotatedWithTraceeContextProvider(final Element element) {
Element parentElement = element.getEnclosingElement();
if (parentElement == null || parentElement.getKind() != ElementKind.CLASS
|| !isTypeAnnot... | Create a Java method that does the following: "Checks if the parent element is annotated with TraceeContextProvider.". |
Of course, here is the Java code you requested:
```java
protected boolean checkIfClassHasNoargsConstructor(TypeElement typeElement) {
// check if annotated class has noargs constructor
boolean foundConstructor = false;
boolean foundNoargsConstructor = false;
for (Element child : typeE... | Create a Java method that does the following: "Check if class has noargs constructor". |
Of course, here is the Java code you requested:
```java
public static List<MethodAnnotationPair> getAnnotatedMethodsOfInstance(final Object instance) {
List<MethodAnnotationPair> result = new ArrayList<MethodAnnotationPair>();
for (Method method : instance.getClass().getDeclaredMethods()) {
... | Create a Java method that does the following: "Gets annotated methods of instance.". |
Of course, here is the Java code you requested:
```java
public static boolean checkMethodHasNonVoidReturnType(final Method method) {
if (method == null) {
return false;
}
try {
return !(Void.TYPE == method.getReturnType());
} catch (Exception e) {
... | Create a Java method that does the following: "Check if a method has a non - void return type.". |
Of course, here is the Java code you requested:
```java
public boolean apply(final StringBuilder stringBuilder, final OutputStyle outputStyle, final OutputElement outputElement) {
boolean result = false;
if (outputElement != null) {
if (OutputElementType.COLLECTION.equals(outputElement.g... | Create a Java method that does the following: "Apply the processing of the tracee context log.". |
Of course, here is the Java code you requested:
```java
public static Set<Class> findWrapperClasses() {
final List<TypeToWrapper> localTypeToWrapperList = getTypeToWrapper();
Set<Class> resultList = new HashSet<Class>();
if (localTypeToWrapperList != null) {
for (TypeToWrapper ty... | Create a Java method that does the following: "Find all wrapper classes.". |
Of course, here is the Java code you requested:
```java
public static List<TypeToWrapper> getAvailableWrappers() {
final List<TypeToWrapper> result = new ArrayList<TypeToWrapper>();
for (Class clazz : ContextProviderServiceLoader.getServiceLocator().getContextProvider()) {
try {
... | Create a Java method that does the following: "Gets the available wrappers.". |
Of course, here is the Java code you requested:
```java
final void sendErrorReportToConnectors(ConnectorOutputProvider connectorOutputProvider) {
for (Connector connector : this.connectorMap.values()) {
connector.sendErrorReport(connectorOutputProvider);
}
}
```
Hope this helps! | Create a Java method that does the following: "Send error report to all connectors.". |
Of course, here is the Java code you requested:
```java
final Set<String> getConnectorConfigurationNames() {
Set<String> connectorNames = new HashSet<String>();
Enumeration<Object> keyEnumeration = getSystemProperties().keys();
while (keyEnumeration.hasMoreElements()) {
String key... | Create a Java method that does the following: "Gets the connector configuration names.". |
Of course, here is the Java code you requested:
```java
final Map<String, String> getPropertiesForConnectorConfigurationName(final String connectorName) {
final Map<String, String> propertyMap = new HashMap<String, String>();
final String patternString = String.format(CONNECTOR_PROPERTY_GRABBER_PATTE... | Create a Java method that does the following: "Gets the properties for the connector configuration name.". |
Of course, here is the Java code you requested:
```java
private boolean isConnectorConfigured(Class connectorClass) {
for (Connector connector : this.connectorMap.values()) {
if (connectorClass.isInstance(connector)) {
return true;
}
}
return false;
... | Create a Java method that does the following: "Checks if a connector class is configured.". |
Of course, here is the Java code you requested:
```java
boolean hasGetterPrefixInMethodName(Method method) {
String methodName = method.getName();
if (methodName != null) {
for (String prefix : GETTER_PREFIXES) {
if (methodName.startsWith(prefix)) {
re... | Create a Java method that does the following: "Checks if a method has a getter prefix that starts with one of the GETTER_PREFIXES.". |
Of course, here is the Java code you requested:
```java
boolean isPublicNonStaticMethod(final Method method) {
int modifiers = method.getModifiers();
return !Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers);
}
```
Hope this helps! | Create a Java method that does the following: "Check if the method is public non - static.". |
Of course, here is the Java code you requested:
```java
boolean hasReturnValue(final Method method) {
Class returnType = method.getReturnType();
return !Void.TYPE.equals(returnType);
}
```
Hope this helps! | Create a Java method that does the following: "Check if the method has a return type.". |
Of course, here is the Java code you requested:
```java
boolean hasCompatibleReturnTypes(Class type, Method method) {
Field correspondingField = getCorrespondingField(type, method);
return correspondingField != null && method.getReturnType().isAssignableFrom(correspondingField.getType());
}
```
... | Create a Java method that does the following: "Checks if the return type of the given method is compatible with the return type of the given class.". |
Of course, here is the Java code you requested:
```java
Field getCorrespondingField(Class type, Method method) {
try {
return type.getDeclaredField(GetterUtilities.getFieldName(method));
}
catch (NoSuchFieldException e) {
return null;
}
}
```
Hope this hel... | Create a Java method that does the following: "Gets the corresponding field of a class and method.". |
Of course, here is the Java code you requested:
```java
public static boolean isGetterMethod(final String methodName) {
if (methodName != null) {
for (String prefix : GETTER_PREFIXES) {
if (methodName.startsWith(prefix)) {
return true;
}
... | Create a Java method that does the following: "Checks if the given method name is a getter method.". |
Of course, here is the Java code you requested:
```java
public static String getFieldName(final String methodName) {
if (isGetterMethod(methodName)) {
return decapitalizeFirstCharOfString(stripGetterPrefix(methodName));
}
return null;
}
```
Hope this helps! | Create a Java method that does the following: "Gets the field name from a getter method name.". |
Of course, here is the Java code you requested:
```java
protected Object invokeGetter(final Object instance, final Method method) {
try {
return method.invoke(instance);
} catch (IllegalAccessException e) {
// shouldn't occur
} catch (InvocationTargetException e) {
// shouldn't occur
}
return null;... | Create a Java method that does the following: "Invoke a getter method on the given instance.". |
Of course, here is the Java code you requested:
```java
public Object apply(ContextLoggerConfiguration contextLoggerConfiguration, Object instanceToWrap) {
// check for implicit context
if (IsImplicitContextEnumValuePredicate.getInstance().apply(instanceToWrap)) {
return createInstance((Class) contextLoggerCon... | Create a Java method that does the following: "This method is called to create a new instance of the context provider.". |
Of course, here is the Java code you requested:
```java
protected boolean isExtendingTraceeContextProvider(final Object instance) {
if (instance == null) {
return false;
}
return WrappedPrimitiveTypeContextData.class.isAssignableFrom(instance.getClass());
}
```
Hope this hel... | Create a Java method that does the following: "Check if the given object is an ExtendingTraceeContextProvider.". |
Of course, here is the Java code you requested:
```java
public static Profile getCurrentProfile() {
// First get profile from system properties
Profile profile = getProfileFromSystemProperties();
// check if profile has been found otherwise try getting profile from file in classpath
if (profile == null) {
... | Create a Java method that does the following: "Get the current profile.". |
Of course, here is the Java code you requested:
```java
static Profile getProfileFromSystemProperties() {
Profile result = null;
// try to get system property
String systemPropertyProfileName = System.getProperty(ProfilePropertyNames.PROFILE_SET_GLOBALLY_VIA_SYSTEM_PROPERTIES);
if (systemPropertyProfileName... | Create a Java method that does the following: "Get the profile from system properties". |
Of course, here is the Java code you requested:
```java
private void fillManualContextOverrideMap(final String[] contexts, final boolean value) {
if (contexts != null) {
for (String context : contexts) {
if (!context.isEmpty()) {
this.manualContextOverrides.put(context, value);
}
}
}
}
```
... | Create a Java method that does the following: "Fill the manual context override map.". |
Of course, here is the Java code you requested:
```java
private TraceeContextStringRepresentationBuilderImpl createContextStringRepresentationLogBuilder() {
TraceeContextStringRepresentationBuilderImpl traceeContextStringRepresentationBuilderImpl = new TraceeContextStringRepresentationBuilderImpl();
traceeContext... | Create a Java method that does the following: "Create a TraceeContextStringRepresentationBuilderImpl.". |
Of course, here is the Java code you requested:
```java
public static Watchdog getWatchdogAnnotation(final ProceedingJoinPoint proceedingJoinPoint) {
// get watchdog annotation from method
MethodSignature methodSignature = (MethodSignature)proceedingJoinPoint.getSignature();
Watchdog methodAnn... | Create a Java method that does the following: "Get the watchdog annotation from the method or declaring class.". |
Of course, here is the Java code you requested:
```java
public static boolean checkProcessWatchdog(final Watchdog watchdogAnnotation, final ProceedingJoinPoint proceedingJoinPoint, final Throwable throwable) {
// check if watchdog aspect processing is deactivated by annotation
if (watchdogAnnotation !=... | Create a Java method that does the following: "Check if watchdog aspect processing is activated by annotation". |
Of course, here is the Java code you requested:
```java
@NotNull LineDiff[] compareContents(@NotNull File actual, @NotNull File expected) throws IOException {
InputStream ais = null;
InputStream eis = null;
try {
ais = new FileInputStream(actual);
eis = new FileInputStream(expected);
List... | Create a Java method that does the following: "Compare two file contents.". |
Of course, here is the Java code you requested:
```java
public final @NotNull S isLessThan(T other) {
isNotNull();
if (actual.compareTo(other) < 0) {
return myself();
}
failIfCustomMessageIsSet();
throw failure(unexpectedGreaterThanOrEqualTo(actual, other));
}
```
Hope this helps! | Create a Java method that does the following: "Fails if the subject is less than the other subject.". |
Of course, here is the Java code you requested:
```java
public final @NotNull S isLessThanOrEqualTo(@Nullable T other) {
isNotNull();
if (actual.compareTo(other) <= 0) {
return myself();
}
failIfCustomMessageIsSet();
throw failure(unexpectedGreaterThan(actual, other));
}
```
Hope this help... | Create a Java method that does the following: "Check if two terms are less than or equal to.". |
Of course, here is the Java code you requested:
```java
public final @NotNull S isGreaterThanOrEqualTo(@Nullable T other) {
isNotNull();
if (actual.compareTo(other) >= 0) {
return myself();
}
failIfCustomMessageIsSet();
throw failure(unexpectedLessThan(actual, other));
}
```
Hope this help... | Create a Java method that does the following: "Checks if two terms are greater than or equal to.". |
Of course, here is the Java code you requested:
```java
@Override
public @NotNull ImageAssert isEqualTo(@Nullable BufferedImage expected) {
return isEqualTo(expected, ZERO_THRESHOLD);
}
```
Hope this helps! | Create a Java method that does the following: "Test if the image is equal to the expected image.". |
Of course, here is the Java code you requested:
```java
public static @NotNull Collection<Object> notFound(@Nullable Collection<?> target, @NotNull Object... objects) {
if (target == null) {
return emptyList();
}
List<Object> notFound = newArrayList();
for (Object o : objects) {
if (!target... | Create a Java method that does the following: "Get the not found objects from the given collection.". |
Of course, here is the Java code you requested:
```java
public @NotNull FileAssert doesNotExist() {
isNotNull();
if (!actual.exists()) {
return this;
}
failIfCustomMessageIsSet();
throw failure(format("file:<%s> should not exist", actual));
}
```
Hope this helps! | Create a Java method that does the following: "Asserts that the file does not exist.". |
Of course, here is the Java code you requested:
```java
public @NotNull FileAssert hasSize(long expected) {
isNotNull();
long size = actual.length();
if (size == expected) {
return this;
}
failIfCustomMessageIsSet();
throw failure(format("size of file:<%s> expected:<%s> but was:<%s>", act... | Create a Java method that does the following: "Asserts that the file contains the given size.". |
Of course, here is the Java code you requested:
```java
public @NotNull FileAssert isDirectory() {
isNotNull();
if (actual.isDirectory()) {
return this;
}
failIfCustomMessageIsSet();
throw failure(format("file:<%s> should be a directory", actual));
}
```
Hope this helps! | Create a Java method that does the following: "Asserts that the file is a directory.". |
Of course, here is the Java code you requested:
```java
public @NotNull FileAssert isFile() {
isNotNull();
if (actual.isFile()) {
return this;
}
failIfCustomMessageIsSet();
throw failure(format("file:<%s> should be a file", actual));
}
```
Hope this helps! | Create a Java method that does the following: "Asserts that the actual is a file.". |
Of course, here is the Java code you requested:
```java
@Override
protected @Nullable List<Object> actualAsList() {
if (actual == null) {
return null;
}
return newArrayList(contentOfActual());
}
```
Hope this helps! | Create a Java method that does the following: "Override to return a list of the actual content of the rule.". |
Of course, here is the Java code you requested:
```java
@NotNull List<Object> propertyValues(@NotNull String propertyName, @Nullable Collection<?> target) {
if (isNullOrEmpty(target)) {
return emptyList();
}
// ignore null elements as we can't extract a property from a null object
Collection<?> n... | Create a Java method that does the following: "Returns a list of values for a property.". |
Of course, here is the Java code you requested:
```java
boolean isNestedProperty(String propertyName) {
Preconditions.checkNotNull(propertyName);
return propertyName.contains(SEPARATOR) && !propertyName.startsWith(SEPARATOR) && !propertyName.endsWith(SEPARATOR);
}
```
Hope this helps! | Create a Java method that does the following: "Checks if the property name is a nested property.". |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.