java.lang.String.contentEquals()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中java.lang.String.contentEquals()方法的一些代码示例,展示了String.contentEquals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。String.contentEquals()方法的具体详情如下:
包路径:java.lang.String
类名称:String
方法名:contentEquals

String.contentEquals介绍

[英]Compares this string to the specified CharSequence. The result is true if and only if this String represents the same sequence of char values as the specified sequence.
[中]将此字符串与指定的字符序列进行比较。当且仅当此字符串表示与指定序列相同的字符值序列时,结果为真。

代码示例

代码示例来源:origin: vavr-io/vavr

/**
 * Compares this string to the specified {@code StringBuffer}.  The result
 * is {@code true} if and only if this {@code CharSeq} represents the same
 * sequence of characters as the specified {@code StringBuffer}. This method
 * synchronizes on the {@code StringBuffer}.
 *
 * @param sb The {@code StringBuffer} to compare this {@code CharSeq} against
 * @return {@code true} if this {@code CharSeq} represents the same
 * sequence of characters as the specified {@code StringBuffer},
 * {@code false} otherwise
 */
public boolean contentEquals(StringBuffer sb) {
  return back.contentEquals(sb);
}

代码示例来源:origin: vavr-io/vavr

/**
 * Compares this string to the specified {@code CharSequence}.  The
 * result is {@code true} if and only if this {@code CharSeq} represents the
 * same sequence of char values as the specified sequence. Note that if the
 * {@code CharSequence} is a {@code StringBuffer} then the method
 * synchronizes on it.
 *
 * @param cs The sequence to compare this {@code CharSeq} against
 * @return {@code true} if this {@code CharSeq} represents the same
 * sequence of char values as the specified sequence, {@code
 * false} otherwise
 */
public boolean contentEquals(CharSequence cs) {
  return back.contentEquals(cs);
}

代码示例来源:origin: marytts/marytts

public void setGvMethod(String sval) {
  if (sval.contentEquals("gradient"))
    gvMethodGradient = true;
  else
    gvMethodGradient = false; // then simple derivative method is used
}

代码示例来源:origin: marytts/marytts

public void setGvMethod(String sval) {
  if (sval.contentEquals("gradient"))
    gvMethodGradient = true;
  else
    gvMethodGradient = false; // then simple derivative method is used
}

代码示例来源:origin: google/guava

/**
 * Returns true if the the given member is a method that overrides {@link Object#equals(Object)}.
 *
 * <p>The documentation for {@link Object#equals} says it should accept null, so don't require an
 * explicit {@code @Nullable} annotation (see <a
 * href="https://github.com/google/guava/issues/1819">#1819</a>).
 *
 * <p>It is not necessary to consider visibility, return type, or type parameter declarations. The
 * declaration of a method with the same name and formal parameters as {@link Object#equals} that
 * is not public and boolean-returning, or that declares any type parameters, would be rejected at
 * compile-time.
 */
private static boolean isEquals(Member member) {
 if (!(member instanceof Method)) {
  return false;
 }
 Method method = (Method) member;
 if (!method.getName().contentEquals("equals")) {
  return false;
 }
 Class<?>[] parameters = method.getParameterTypes();
 if (parameters.length != 1) {
  return false;
 }
 if (!parameters[0].equals(Object.class)) {
  return false;
 }
 return true;
}

代码示例来源:origin: OpenHFT/Chronicle-Queue

private static int indexOfLastZero(@NotNull CharSequence str) {
    int i = str.length() - 3;
    do {
      i -= LENGTH;
      CharSequence charSequence = str.subSequence(i, i + 3);
      if (!", 0".contentEquals(charSequence))
        return i + LENGTH;
    } while (i > 3);
    return 0;
  }
}

代码示例来源:origin: bwssytems/ha-bridge

public Boolean validateType(String type) {
    if(type == null || type.trim().isEmpty())
      return false;
    for(String classType : groupClassTypes) {
      if(type.trim().contentEquals(classType))
        return true;
    }
    return false;
  }
}

代码示例来源:origin: google/error-prone

@Override
public boolean contentEquals(@Nullable CharSequence cs) {
 return cs != null && contents().contentEquals(cs);
}

代码示例来源:origin: eclipse-vertx/vert.x

/**
 * Like {@link #contains(String, String, boolean)} but accepting {@code CharSequence} parameters.
 */
@GenIgnore(GenIgnore.PERMITTED_TYPE)
default boolean contains(CharSequence name, CharSequence value, boolean caseInsensitive) {
 Predicate<String> predicate;
 if (caseInsensitive) {
  String valueAsString = value.toString();
  predicate = val -> val.equalsIgnoreCase(valueAsString);
 } else {
  predicate = val -> val.contentEquals(value);
 }
 return getAll(name).stream().anyMatch(predicate);
}

代码示例来源:origin: apache/nifi

protected byte[] getRow(final String row, final String encoding) {
  //check to see if we need to modify the rowKey before we pass it down to the PutFlowFile
  byte[] rowKeyBytes = null;
  if(BINARY_ENCODING_VALUE.contentEquals(encoding)){
    rowKeyBytes = clientService.toBytesBinary(row);
  }else{
    rowKeyBytes = row.getBytes(StandardCharsets.UTF_8);
  }
  return rowKeyBytes;
}
/**

代码示例来源:origin: internetarchive/heritrix3

public static boolean isLikelyUriJavascriptContextLegacy(CharSequence candidate) {
  if(!TextUtils.matches(STRING_URI_DETECTOR,candidate)) {
    return false; 
  }
  for (String s : STRING_URI_DETECTOR_EXCEPTIONS) {
    if (s.contentEquals(candidate)) 
      return false;
  }
  // matches detector and not an exception: so a likely URI
  return true; 
}

代码示例来源:origin: libgdx/libgdx

/** Sets the first {@link TextButton} with the specified text to checked. */
public void setChecked (String text) {
  if (text == null) throw new IllegalArgumentException("text cannot be null.");
  for (int i = 0, n = buttons.size; i < n; i++) {
    T button = buttons.get(i);
    if (button instanceof TextButton && text.contentEquals(((TextButton)button).getText())) {
      button.setChecked(true);
      return;
    }
  }
}

代码示例来源:origin: libgdx/libgdx

/** Sets the first {@link TextButton} with the specified text to checked. */
public void setChecked (String text) {
  if (text == null) throw new IllegalArgumentException("text cannot be null.");
  for (int i = 0, n = buttons.size; i < n; i++) {
    T button = buttons.get(i);
    if (button instanceof TextButton && text.contentEquals(((TextButton)button).getText())) {
      button.setChecked(true);
      return;
    }
  }
}

代码示例来源:origin: google/guava

static String iterationOrder(Iterable<? extends Node> iterable) {
 StringBuilder builder = new StringBuilder();
 for (Node t : iterable) {
  builder.append(t.value);
 }
 StringBuilder forEachBuilder = new StringBuilder();
 iterable.forEach(t -> forEachBuilder.append(t.value));
 assertTrue(
   "Iterator content was " + builder + " but forEach content was " + forEachBuilder,
   builder.toString().contentEquals(forEachBuilder));
 return builder.toString();
}

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * Ask for the Operating system name.
 *
 * @return a string that contains the current Operating System.
 */
private String getEnvironmentName() {
 String osName = getOsName();
 if ( osName.contentEquals( "linux" ) ) {
  return osName + " " + getLinuxDistribution().toLowerCase();
 }
 return osName;
}

代码示例来源:origin: OpenHFT/Chronicle-Queue

@NotNull
private LongArrayValues array(@NotNull WireIn w, @NotNull LongArrayValues using, boolean index2index) {
  final StringBuilder sb = Wires.acquireStringBuilder();
  @NotNull final ValueIn valueIn = w.readEventName(sb);
  String name = index2index ? "index2index" : "index";
  if (!name.contentEquals(sb))
    throw new IllegalStateException("expecting index, was " + sb);
  valueIn.int64array(using, this, (o1, o2) -> {
  });
  return using;
}

代码示例来源:origin: OpenHFT/Chronicle-Queue

private static MessageHistory readHistoryFromWire(final Wire wire, MessageHistory history) {
  final StringBuilder sb = SBP.acquireStringBuilder();
  ValueIn valueIn = wire.read(sb);
  if (!MethodReader.HISTORY.contentEquals(sb))
    return null;
  valueIn.object(history, MessageHistory.class);
  return history;
}

代码示例来源:origin: wildfly/wildfly

/**
 * Returns the {@link HttpResponseStatus} represented by the specified {@code code} and {@code reasonPhrase}.
 * If the specified code is a standard HTTP status {@code code} and {@code reasonPhrase}, a cached instance
 * will be returned. Otherwise, a new instance will be returned.
 * @param code The response code value.
 * @param reasonPhrase The response code reason phrase.
 * @return the {@link HttpResponseStatus} represented by the specified {@code code} and {@code reasonPhrase}.
 */
public static HttpResponseStatus valueOf(int code, String reasonPhrase) {
  HttpResponseStatus responseStatus = valueOf0(code);
  return responseStatus != null && responseStatus.reasonPhrase().contentEquals(reasonPhrase) ? responseStatus :
      new HttpResponseStatus(code, reasonPhrase);
}

代码示例来源:origin: google/error-prone

@Override
 public JCExpression staticReference(
   Inliner inliner,
   CharSequence topLevelClazz,
   CharSequence fullyQualifiedClazz,
   CharSequence member) {
  if (Refaster.class.getName().contentEquals(topLevelClazz)) {
   // Special handling to ensure that the pretty-printer always recognizes Refaster references
   return inliner
     .maker()
     .Select(inliner.maker().Ident(inliner.asName("Refaster")), inliner.asName(member));
  }
  inliner.addStaticImport(fullyQualifiedClazz + "." + member);
  return inliner.maker().Ident(inliner.asName(member));
 }
};

代码示例来源:origin: google/error-prone

@Override
 public JCExpression staticReference(
   Inliner inliner,
   CharSequence topLevelClazz,
   CharSequence fullyQualifiedClazz,
   CharSequence member) {
  if (Refaster.class.getName().contentEquals(topLevelClazz)) {
   // Special handling to ensure that the pretty-printer always recognizes Refaster references
   return inliner
     .maker()
     .Select(inliner.maker().Ident(inliner.asName("Refaster")), inliner.asName(member));
  }
  return inliner
    .maker()
    .Select(
      classReference(inliner, topLevelClazz, fullyQualifiedClazz), inliner.asName(member));
 }
},

相关文章

微信公众号

最新文章

更多