org.springframework.core.Constants.getValues()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(12.9k)|赞(0)|评价(0)|浏览(120)

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

Constants.getValues介绍

[英]Return all values of the given group of constants.

Note that this method assumes that constants are named in accordance with the standard Java convention for constant values (i.e. all uppercase). The supplied namePrefixwill be uppercased (in a locale-insensitive fashion) prior to the main logic of this method kicking in.
[中]返回给定常量组的所有值。
请注意,此方法假定常量的命名符合常量值的标准Java约定(即所有大写)。在该方法的主逻辑开始之前,提供的NamePrefix将以大写形式(不区分区域设置)显示。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Set the autodetection mode to use.
 * @throws IllegalArgumentException if the supplied value is not
 * one of the {@code AUTODETECT_} constants
 * @see #setAutodetectModeName(String)
 * @see #AUTODETECT_ALL
 * @see #AUTODETECT_ASSEMBLER
 * @see #AUTODETECT_MBEAN
 * @see #AUTODETECT_NONE
 */
public void setAutodetectMode(int autodetectMode) {
  if (!constants.getValues(CONSTANT_PREFIX_AUTODETECT).contains(autodetectMode)) {
    throw new IllegalArgumentException("Only values of autodetect constants allowed");
  }
  this.autodetectMode = autodetectMode;
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void getValues() {
  Constants c = new Constants(A.class);
  Set<?> values = c.getValues("");
  assertEquals(7, values.size());
  assertTrue(values.contains(Integer.valueOf(0)));
  assertTrue(values.contains(Integer.valueOf(66)));
  assertTrue(values.contains(""));
  values = c.getValues("D");
  assertEquals(1, values.size());
  assertTrue(values.contains(Integer.valueOf(0)));
  values = c.getValues("prefix");
  assertEquals(2, values.size());
  assertTrue(values.contains(Integer.valueOf(1)));
  assertTrue(values.contains(Integer.valueOf(2)));
  values = c.getValuesForProperty("myProperty");
  assertEquals(2, values.size());
  assertTrue(values.contains(Integer.valueOf(1)));
  assertTrue(values.contains(Integer.valueOf(2)));
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Set the isolation level. Must be one of the isolation constants
 * in the TransactionDefinition interface. Default is ISOLATION_DEFAULT.
 * <p>Exclusively designed for use with {@link #PROPAGATION_REQUIRED} or
 * {@link #PROPAGATION_REQUIRES_NEW} since it only applies to newly started
 * transactions. Consider switching the "validateExistingTransactions" flag to
 * "true" on your transaction manager if you'd like isolation level declarations
 * to get rejected when participating in an existing transaction with a different
 * isolation level.
 * <p>Note that a transaction manager that does not support custom isolation levels
 * will throw an exception when given any other level than {@link #ISOLATION_DEFAULT}.
 * @throws IllegalArgumentException if the supplied value is not one of the
 * {@code ISOLATION_} constants
 * @see #ISOLATION_DEFAULT
 */
public final void setIsolationLevel(int isolationLevel) {
  if (!constants.getValues(PREFIX_ISOLATION).contains(isolationLevel)) {
    throw new IllegalArgumentException("Only values of isolation constants allowed");
  }
  this.isolationLevel = isolationLevel;
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void getValuesInTurkey() {
  Locale oldLocale = Locale.getDefault();
  Locale.setDefault(new Locale("tr", ""));
  try {
    Constants c = new Constants(A.class);
    Set<?> values = c.getValues("");
    assertEquals(7, values.size());
    assertTrue(values.contains(Integer.valueOf(0)));
    assertTrue(values.contains(Integer.valueOf(66)));
    assertTrue(values.contains(""));
    values = c.getValues("D");
    assertEquals(1, values.size());
    assertTrue(values.contains(Integer.valueOf(0)));
    values = c.getValues("prefix");
    assertEquals(2, values.size());
    assertTrue(values.contains(Integer.valueOf(1)));
    assertTrue(values.contains(Integer.valueOf(2)));
    values = c.getValuesForProperty("myProperty");
    assertEquals(2, values.size());
    assertTrue(values.contains(Integer.valueOf(1)));
    assertTrue(values.contains(Integer.valueOf(2)));
  }
  finally {
    Locale.setDefault(oldLocale);
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Specify the default isolation level to use for Connection retrieval,
 * according to the JDBC {@link java.sql.Connection} constants
 * (equivalent to the corresponding Spring
 * {@link org.springframework.transaction.TransactionDefinition} constants).
 * <p>If not specified, the target DataSource's default will be used.
 * Note that a transaction-specific isolation value will always override
 * any isolation setting specified at the DataSource level.
 * @see java.sql.Connection#TRANSACTION_READ_UNCOMMITTED
 * @see java.sql.Connection#TRANSACTION_READ_COMMITTED
 * @see java.sql.Connection#TRANSACTION_REPEATABLE_READ
 * @see java.sql.Connection#TRANSACTION_SERIALIZABLE
 * @see org.springframework.transaction.TransactionDefinition#ISOLATION_READ_UNCOMMITTED
 * @see org.springframework.transaction.TransactionDefinition#ISOLATION_READ_COMMITTED
 * @see org.springframework.transaction.TransactionDefinition#ISOLATION_REPEATABLE_READ
 * @see org.springframework.transaction.TransactionDefinition#ISOLATION_SERIALIZABLE
 * @see org.springframework.transaction.TransactionDefinition#getIsolationLevel()
 * @see org.springframework.transaction.support.TransactionSynchronizationManager#getCurrentTransactionIsolationLevel()
 */
public void setIsolationLevel(int isolationLevel) {
  if (!constants.getValues(DefaultTransactionDefinition.PREFIX_ISOLATION).contains(isolationLevel)) {
    throw new IllegalArgumentException("Only values of isolation constants allowed");
  }
  this.isolationLevel = (isolationLevel != TransactionDefinition.ISOLATION_DEFAULT ? isolationLevel : null);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Set the propagation behavior. Must be one of the propagation constants
 * in the TransactionDefinition interface. Default is PROPAGATION_REQUIRED.
 * <p>Exclusively designed for use with {@link #PROPAGATION_REQUIRED} or
 * {@link #PROPAGATION_REQUIRES_NEW} since it only applies to newly started
 * transactions. Consider switching the "validateExistingTransactions" flag to
 * "true" on your transaction manager if you'd like isolation level declarations
 * to get rejected when participating in an existing transaction with a different
 * isolation level.
 * <p>Note that a transaction manager that does not support custom isolation levels
 * will throw an exception when given any other level than {@link #ISOLATION_DEFAULT}.
 * @throws IllegalArgumentException if the supplied value is not one of the
 * {@code PROPAGATION_} constants
 * @see #PROPAGATION_REQUIRED
 */
public final void setPropagationBehavior(int propagationBehavior) {
  if (!constants.getValues(PREFIX_PROPAGATION).contains(propagationBehavior)) {
    throw new IllegalArgumentException("Only values of propagation constants allowed");
  }
  this.propagationBehavior = propagationBehavior;
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Return all values of the group of constants for the
 * given bean property name.
 * @param propertyName the name of the bean property
 * @return the set of values
 * @see #propertyToConstantNamePrefix
 */
public Set<Object> getValuesForProperty(String propertyName) {
  return getValues(propertyToConstantNamePrefix(propertyName));
}

代码示例来源:origin: org.springframework/spring-context

/**
 * Set the autodetection mode to use.
 * @throws IllegalArgumentException if the supplied value is not
 * one of the {@code AUTODETECT_} constants
 * @see #setAutodetectModeName(String)
 * @see #AUTODETECT_ALL
 * @see #AUTODETECT_ASSEMBLER
 * @see #AUTODETECT_MBEAN
 * @see #AUTODETECT_NONE
 */
public void setAutodetectMode(int autodetectMode) {
  if (!constants.getValues(CONSTANT_PREFIX_AUTODETECT).contains(autodetectMode)) {
    throw new IllegalArgumentException("Only values of autodetect constants allowed");
  }
  this.autodetectMode = autodetectMode;
}

代码示例来源:origin: org.springframework/spring-core

/**
 * Return all values of the group of constants for the
 * given bean property name.
 * @param propertyName the name of the bean property
 * @return the set of values
 * @see #propertyToConstantNamePrefix
 */
public Set<Object> getValuesForProperty(String propertyName) {
  return getValues(propertyToConstantNamePrefix(propertyName));
}

代码示例来源:origin: org.springframework/spring-tx

/**
 * Set the isolation level. Must be one of the isolation constants
 * in the TransactionDefinition interface. Default is ISOLATION_DEFAULT.
 * <p>Exclusively designed for use with {@link #PROPAGATION_REQUIRED} or
 * {@link #PROPAGATION_REQUIRES_NEW} since it only applies to newly started
 * transactions. Consider switching the "validateExistingTransactions" flag to
 * "true" on your transaction manager if you'd like isolation level declarations
 * to get rejected when participating in an existing transaction with a different
 * isolation level.
 * <p>Note that a transaction manager that does not support custom isolation levels
 * will throw an exception when given any other level than {@link #ISOLATION_DEFAULT}.
 * @throws IllegalArgumentException if the supplied value is not one of the
 * {@code ISOLATION_} constants
 * @see #ISOLATION_DEFAULT
 */
public final void setIsolationLevel(int isolationLevel) {
  if (!constants.getValues(PREFIX_ISOLATION).contains(isolationLevel)) {
    throw new IllegalArgumentException("Only values of isolation constants allowed");
  }
  this.isolationLevel = isolationLevel;
}

代码示例来源:origin: org.springframework/spring-tx

/**
 * Set the propagation behavior. Must be one of the propagation constants
 * in the TransactionDefinition interface. Default is PROPAGATION_REQUIRED.
 * <p>Exclusively designed for use with {@link #PROPAGATION_REQUIRED} or
 * {@link #PROPAGATION_REQUIRES_NEW} since it only applies to newly started
 * transactions. Consider switching the "validateExistingTransactions" flag to
 * "true" on your transaction manager if you'd like isolation level declarations
 * to get rejected when participating in an existing transaction with a different
 * isolation level.
 * <p>Note that a transaction manager that does not support custom isolation levels
 * will throw an exception when given any other level than {@link #ISOLATION_DEFAULT}.
 * @throws IllegalArgumentException if the supplied value is not one of the
 * {@code PROPAGATION_} constants
 * @see #PROPAGATION_REQUIRED
 */
public final void setPropagationBehavior(int propagationBehavior) {
  if (!constants.getValues(PREFIX_PROPAGATION).contains(propagationBehavior)) {
    throw new IllegalArgumentException("Only values of propagation constants allowed");
  }
  this.propagationBehavior = propagationBehavior;
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void getValuesWithNullPrefix() throws Exception {
  Constants c = new Constants(A.class);
  Set<?> values = c.getValues(null);
  assertEquals("Must have returned *all* public static final values", 7, values.size());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void getValuesWithEmptyStringPrefix() throws Exception {
  Constants c = new Constants(A.class);
  Set<Object> values = c.getValues("");
  assertEquals("Must have returned *all* public static final values", 7, values.size());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void getValuesWithWhitespacedStringPrefix() throws Exception {
  Constants c = new Constants(A.class);
  Set<?> values = c.getValues(" ");
  assertEquals("Must have returned *all* public static final values", 7, values.size());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void withClassThatExposesNoConstants() throws Exception {
  Constants c = new Constants(NoConstants.class);
  assertEquals(0, c.getSize());
  final Set<?> values = c.getValues("");
  assertNotNull(values);
  assertEquals(0, values.size());
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Return all values of the group of constants for the
 * given bean property name.
 * @param propertyName the name of the bean property
 * @return the set of values
 * @see #propertyToConstantNamePrefix
 */
public Set<Object> getValuesForProperty(String propertyName) {
  return getValues(propertyToConstantNamePrefix(propertyName));
}

代码示例来源:origin: springframework/spring-dao

/**
 * Set the propagation behavior. Must be one of the propagation constants
 * in the TransactionDefinition interface. Default is PROPAGATION_REQUIRED.
 * @see #PROPAGATION_REQUIRED
 */
public final void setPropagationBehavior(int propagationBehavior) {
  if (!constants.getValues(PROPAGATION_CONSTANT_PREFIX).contains(new Integer(propagationBehavior))) {
    throw new IllegalArgumentException("Only values of propagation constants allowed");
  }
  this.propagationBehavior = propagationBehavior;
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Return all values of the group of constants for the
 * given bean property name.
 * @param propertyName the name of the bean property
 * @return the set of values
 * @see #propertyToConstantNamePrefix
 */
public Set<Object> getValuesForProperty(String propertyName) {
  return getValues(propertyToConstantNamePrefix(propertyName));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core

/**
 * Return all values of the group of constants for the
 * given bean property name.
 * @param propertyName the name of the bean property
 * @return the set of values
 * @see #propertyToConstantNamePrefix
 */
public Set<Object> getValuesForProperty(String propertyName) {
  return getValues(propertyToConstantNamePrefix(propertyName));
}

代码示例来源:origin: springframework/spring-core

/**
 * Return all values of the group of constants for the
 * given bean property name.
 * @param propertyName the name of the bean property
 * @return the set of values
 * @see #propertyToConstantNamePrefix
 */
public Set getValuesForProperty(String propertyName) {
  return getValues(propertyToConstantNamePrefix(propertyName));
}

相关文章