Example usage for java.lang CharSequence equals

List of usage examples for java.lang CharSequence equals

Introduction

In this page you can find the example usage for java.lang CharSequence equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:fr.landel.utils.assertor.utils.AssertorEnum.java

/**
 * Prepare the next step to validate if the {@link Enum} has the specified
 * name/*from www .j  a v  a 2s. c  om*/
 * 
 * <p>
 * precondition: {@link Enum} cannot be null and {@code name} cannot be
 * {@code null} or empty
 * </p>
 * 
 * @param step
 *            the previous step
 * @param name
 *            the enumeration property name
 * @param message
 *            the message if invalid
 * @param <T>
 *            the enumeration type
 * @return the next step
 */
public static <T extends Enum<T>> StepAssertor<T> hasName(final StepAssertor<T> step, final CharSequence name,
        final MessageAssertor message) {

    final BiPredicate<T, Boolean> checker = (object, not) -> name.equals(object.name());

    return AssertorEnum.hasName(step, name, MSG.ENUM.NAME, checker, message);
}

From source file:Main.java

public static boolean equals(CharSequence a, CharSequence b) {
    if (a == b)// w w  w. j  av a 2 s.c  o m
        return true;
    int length;
    if (a != null && b != null && (length = a.length()) == b.length()) {
        if (a instanceof String && b instanceof String) {
            return a.equals(b);
        } else {
            for (int i = 0; i < length; i++) {
                if (a.charAt(i) != b.charAt(i))
                    return false;
            }
            return true;
        }
    }
    return false;
}

From source file:Main.java

/**
 * Returns true if a and b are equal, including if they are both null.
 * <p><i>Note: In platform versions 1.1 and earlier, this method only worked well if
 * both the arguments were instances of String.</i></p>
 *
 * @param a first CharSequence to check//from ww  w .j  av a 2  s .  co  m
 * @param b second CharSequence to check
 *
 * @return true if a and b are equal
 *
 * NOTE: Logic slightly change due to strict policy on CI -
 * "Inner assignments should be avoided"
 */
static boolean equals(CharSequence a, CharSequence b) {
    if (a == b)
        return true;
    if (a != null && b != null) {
        int length = a.length();
        if (length == b.length()) {
            if (a instanceof String && b instanceof String) {
                return a.equals(b);
            } else {
                for (int i = 0; i < length; i++) {
                    if (a.charAt(i) != b.charAt(i))
                        return false;
                }
                return true;
            }
        }
    }
    return false;
}

From source file:com.simiacryptus.mindseye.lang.Layer.java

/**
 * From zip nn key./*from w  ww  .ja v  a  2s . c o  m*/
 *
 * @param zipfile the zipfile
 * @return the nn key
 */
@Nonnull
static Layer fromZip(@Nonnull final ZipFile zipfile) {
    Enumeration<? extends ZipEntry> entries = zipfile.entries();
    @Nullable
    JsonObject json = null;
    @Nonnull
    HashMap<CharSequence, byte[]> resources = new HashMap<>();
    while (entries.hasMoreElements()) {
        ZipEntry zipEntry = entries.nextElement();
        CharSequence name = zipEntry.getName();
        try {
            InputStream inputStream = zipfile.getInputStream(zipEntry);
            if (name.equals("model.json")) {
                json = new GsonBuilder().create().fromJson(new InputStreamReader(inputStream),
                        JsonObject.class);
            } else {
                resources.put(name, IOUtils.readFully(inputStream, (int) zipEntry.getSize()));
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    return fromJson(json, resources);
}

From source file:org.apache.drill.common.logical.data.Project.java

@JsonCreator
public Project(@JsonProperty("projections") NamedExpression[] selections) {
    this.selections = selections;
    if (selections == null || selections.length == 0)
        throw new ExpressionParsingException(
                "Project did not provide any projection selections.  At least one projection must be provided.");
    for (int i = 0; i < selections.length; i++) {
        PathSegment segment = selections[i].getRef().getRootSegment();
        CharSequence path = segment.getNameSegment().getPath();
        if (!segment.isNamed() || !path.equals("output"))
            throw new ExpressionParsingException(String.format(
                    "Outputs for projections always have to start with named path of output. First segment was named '%s' or was named [%s]",
                    path, segment.isNamed()));

    }//from  w  w w.j a v  a  2  s  .  c  o m
}

From source file:com.google.android.gcm.demo.ui.MainMenu.java

public boolean onOverflowMenuItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.toggle_logs: {
        CharSequence showLogs = mActivity.getString(R.string.show_logs);
        if (showLogs.equals(item.getTitle())) {
            mActivity.toggleLogsView(true);
            item.setTitle(R.string.hide_logs);
            item.setIcon(R.drawable.visibility_off_white);
        } else {/*from  w w  w. j  a  v  a 2 s .c  om*/
            mActivity.toggleLogsView(false);
            item.setTitle(R.string.show_logs);
            item.setIcon(R.drawable.visibility_white);
        }
        return true;
    }
    case R.id.clear_logs: {
        (new Logger(mActivity)).clearLogs();
        return true;
    }
    default:
        return false;
    }
}

From source file:com.klinker.android.twitter.activities.compose.NotificationDMCompose.java

@Override
public void setUpLayout() {
    super.setUpLayout();

    // mark the messages as read here
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(1);//from   w  w  w . j av a  2s  .co  m

    sharedPrefs.edit().putInt("dm_unread_" + currentAccount, 0).commit();

    notiId = 1;
    replyText = sharedPrefs.getString("from_notification_text", "");
    sharedPrefs.edit().putString("from_notification_text", "").commit();

    contactEntry.setText(sharedPrefs.getString("from_notification", "").replace(" ", ""));
    reply.requestFocus();

    // try from android wear device
    CharSequence voiceReply = getVoiceReply(getIntent());
    if (voiceReply != null) {
        if (!voiceReply.equals("")) {
            // set the text
            reply.setText(voiceReply);

            // send the message
            doneClick();

            finish();
        }
    }
}

From source file:com.omnigon.aem.handlebars.helpers.InHelper.java

/**
 *
 * @param target target param.//from ww w.j  ava2s.co  m
 * @param options the thing being compared.
 * @return true/false or if true and there is an inner block, that content.
 * @throws IOException
 */
@Override
public CharSequence apply(final Object target, final Options options) throws IOException {
    if (!isValidComparableStringParam(target) || !isValidPrefixParam(options)) {
        return null;
    }

    CharSequence comparableString = (CharSequence) target;
    for (Object param : options.params) {
        if (comparableString.equals(param.toString())) {
            return options.fn();
        }
    }

    return options.inverse();
}

From source file:com.klinker.android.twitter.activities.compose.NotificationCompose.java

@Override
public void setUpReplyText() {
    // mark the messages as read here
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(1);/*from   www  .j a v a 2 s . c o  m*/
    mNotificationManager.cancel(9);

    sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    Context context = getApplicationContext();
    int currentAccount = sharedPrefs.getInt("current_account", 1);

    // we can just mark everything as read because it isnt taxing at all and won't do anything in the mentions if there isn't one
    // and the shared prefs are easy.
    // this is only called from the notification and there will only ever be one thing that is unread when this button is available

    MentionsDataSource.getInstance(context).markAllRead(currentAccount);

    // set up the reply box
    sharedPrefs.edit().putInt("dm_unread_" + currentAccount, 0).commit();
    reply.setText(sharedPrefs.getString("from_notification", ""));
    reply.setSelection(reply.getText().toString().length());
    notiId = sharedPrefs.getLong("from_notification_long", 0);
    replyText = sharedPrefs.getString("from_notification_text", "");

    sharedPrefs.edit().putLong("from_notification_id", 0).commit();
    sharedPrefs.edit().putString("from_notification_text", "").commit();
    sharedPrefs.edit().putString("from_notification", "").commit();
    sharedPrefs.edit().putBoolean("from_notification_bool", false).commit();

    String t = reply.getText().toString();
    if (!android.text.TextUtils.isEmpty(t) && !t.endsWith(" ")) {
        reply.append(" ");
        reply.setSelection(reply.getText().length());
    }

    // try from android wear device
    CharSequence voiceReply = getVoiceReply(getIntent());
    if (voiceReply != null) {
        if (!voiceReply.equals("")) {
            // set the text
            reply.append(voiceReply);

            // send the message
            doneClick();

            finish();
        }
    }
}

From source file:com.fuzz.emptyhusk.SimplePagerAdapter.java

@Override
public boolean isViewFromObject(View view, Object object) {
    TextView textView = (TextView) view.findViewById(R.id.cell_text);
    CharSequence text = null;

    if (textView != null) {
        text = textView.getText();/*  www.  j a v  a 2s  .c o m*/
    }

    return text != null && text.equals(object);
}