自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
OptionUpdateRule
public
final
enum
OptionUpdateRule
extends Enum<OptionUpdateRule>
控制多次指定选项时的行为。请注意,此枚举假定要设置的值不是 ERROR(/Collection)
或 ERROR(/Map)
。
摘要
枚举值
公共方法
shouldUpdate
public boolean shouldUpdate (String optionName,
Object optionSource,
Field field,
Object update)
接受当前值和更新值,并返回是否应更新值。假设 update
从来不会为 null。
参数 |
optionName |
String |
optionSource |
Object |
field |
Field |
update |
Object |
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# OptionUpdateRule\n================\n\n\n`\npublic\n\nfinal\n\nenum\nOptionUpdateRule\n`\n\n\n`\n\n\n`\n\n`\n\nextends Enum\u003c`[OptionUpdateRule](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html)`\u003e\n\n\n`\n\n`\n\n\n`\n\n|---|---|----------------------------------------------|\n| java.lang.Object |||\n| ↳ | java.lang.Enum\\\u003c[com.android.tradefed.config.OptionUpdateRule](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html)\\\u003e ||\n| | ↳ | com.android.tradefed.config.OptionUpdateRule |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nControls the behavior when an option is specified multiple times. Note that this enum assumes\nthat the values to be set are not [ERROR(/Collection)](../../../../../../)s or [ERROR(/Map)](../../../../../../)s.\n\nSummary\n-------\n\n| ### Enum values ||\n|------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [OptionUpdateRule](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html) | `FIRST` once an option is set, subsequent attempts to update it should be ignored. |\n| [OptionUpdateRule](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html) | `GREATEST` for [Comparable](../../../../../../reference/tradefed/java/lang/Comparable.html) options, keep the one that compares as the greatest. |\n| [OptionUpdateRule](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html) | `IMMUTABLE` throw a [ConfigurationException](../../../../../../reference/tradefed/com/android/tradefed/config/ConfigurationException.html) if this option is set more than once. |\n| [OptionUpdateRule](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html) | `LAST` if an option is set multiple times, ignore all but the last value. |\n| [OptionUpdateRule](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html) | `LEAST` for [Comparable](../../../../../../reference/tradefed/java/lang/Comparable.html) options, keep the one that compares as the least. |\n\n| ### Public methods ||\n|------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` boolean` | ` `[shouldUpdate](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html#shouldUpdate(java.lang.String,%20java.lang.Object,%20Field,%20java.lang.Object))`(String optionName, Object optionSource, Field field, Object update) ` Takes the current value and the update value, and returns whether the value should be updated. |\n| ` static `[OptionUpdateRule](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html) | ` `[valueOf](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html#valueOf(java.lang.String))`(String name) ` |\n| ` static final `[OptionUpdateRule[]](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html) | ` `[values](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html#values())`() ` |\n\nEnum values\n-----------\n\n### FIRST\n\n```\npublic static final OptionUpdateRule FIRST\n```\n\nonce an option is set, subsequent attempts to update it should be ignored.\n\n\u003cbr /\u003e\n\n### GREATEST\n\n```\npublic static final OptionUpdateRule GREATEST\n```\n\nfor [Comparable](../../../../../../reference/tradefed/java/lang/Comparable.html) options, keep the one that compares as the greatest.\n\n\u003cbr /\u003e\n\n### IMMUTABLE\n\n```\npublic static final OptionUpdateRule IMMUTABLE\n```\n\nthrow a [ConfigurationException](../../../../../../reference/tradefed/com/android/tradefed/config/ConfigurationException.html) if this option is set more than once.\n\n\u003cbr /\u003e\n\n### LAST\n\n```\npublic static final OptionUpdateRule LAST\n```\n\nif an option is set multiple times, ignore all but the last value.\n\n\u003cbr /\u003e\n\n### LEAST\n\n```\npublic static final OptionUpdateRule LEAST\n```\n\nfor [Comparable](../../../../../../reference/tradefed/java/lang/Comparable.html) options, keep the one that compares as the least.\n\n\u003cbr /\u003e\n\nPublic methods\n--------------\n\n### shouldUpdate\n\n```\npublic boolean shouldUpdate (String optionName, \n Object optionSource, \n Field field, \n Object update)\n```\n\nTakes the current value and the update value, and returns whether the value should be\nupdated. Assumes that `update` is never null.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------------|-----------------|\n| `optionName` | `String` \u003cbr /\u003e |\n| `optionSource` | `Object` \u003cbr /\u003e |\n| `field` | `Field` \u003cbr /\u003e |\n| `update` | `Object` \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------|\n| `boolean` | \u003cbr /\u003e |\n\n| Throws ||\n|------------------------------------------------------------------------------------------------------------------------|---|\n| [ConfigurationException](../../../../../../reference/tradefed/com/android/tradefed/config/ConfigurationException.html) | |\n\n### valueOf\n\n```\npublic static OptionUpdateRule valueOf (String name)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|-----------------|\n| `name` | `String` \u003cbr /\u003e |\n\n| Returns ||\n|------------------------------------------------------------------------------------------------------------|--------|\n| [OptionUpdateRule](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html) | \u003cbr /\u003e |\n\n### values\n\n```\npublic static final OptionUpdateRule[] values ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|--------------------------------------------------------------------------------------------------------------|--------|\n| [OptionUpdateRule[]](../../../../../../reference/tradefed/com/android/tradefed/config/OptionUpdateRule.html) | \u003cbr /\u003e |"]]