├── .asf.yaml ├── .gitattributes ├── .github ├── GH-ROBOTS.txt ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── codeql-analysis.yml │ ├── dependency-review.yml │ ├── maven.yml │ └── scorecards-analysis.yml ├── .gitignore ├── .mvn └── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── RELEASE-NOTES.txt ├── SECURITY.md ├── pom.xml └── src ├── assembly ├── bin.xml └── src.xml ├── changes ├── changes.xml └── release-notes.vm ├── conf ├── checkstyle │ └── import-control.xml ├── pmd-exclude.properties ├── pmd-ruleset.xml └── spotbugs-exclude-filter.xml ├── main └── java │ └── org │ └── apache │ └── commons │ └── lang3 │ ├── AnnotationUtils.java │ ├── AppendableJoiner.java │ ├── ArchUtils.java │ ├── ArrayFill.java │ ├── ArraySorter.java │ ├── ArrayUtils.java │ ├── BitField.java │ ├── BooleanUtils.java │ ├── CachedRandomBits.java │ ├── CharEncoding.java │ ├── CharRange.java │ ├── CharSequenceUtils.java │ ├── CharSet.java │ ├── CharSetUtils.java │ ├── CharUtils.java │ ├── Charsets.java │ ├── ClassLoaderUtils.java │ ├── ClassPathUtils.java │ ├── ClassUtils.java │ ├── Conversion.java │ ├── DoubleRange.java │ ├── EnumUtils.java │ ├── Functions.java │ ├── IntegerRange.java │ ├── JavaVersion.java │ ├── LocaleUtils.java │ ├── LongRange.java │ ├── NotImplementedException.java │ ├── NumberRange.java │ ├── ObjectUtils.java │ ├── RandomStringUtils.java │ ├── RandomUtils.java │ ├── Range.java │ ├── RegExUtils.java │ ├── RuntimeEnvironment.java │ ├── SerializationException.java │ ├── SerializationUtils.java │ ├── Streams.java │ ├── StringEscapeUtils.java │ ├── StringUtils.java │ ├── Strings.java │ ├── SystemProperties.java │ ├── SystemUtils.java │ ├── ThreadUtils.java │ ├── Validate.java │ ├── arch │ ├── Processor.java │ └── package-info.java │ ├── builder │ ├── AbstractSupplier.java │ ├── Builder.java │ ├── CompareToBuilder.java │ ├── Diff.java │ ├── DiffBuilder.java │ ├── DiffExclude.java │ ├── DiffResult.java │ ├── Diffable.java │ ├── EqualsBuilder.java │ ├── EqualsExclude.java │ ├── HashCodeBuilder.java │ ├── HashCodeExclude.java │ ├── IDKey.java │ ├── MultilineRecursiveToStringStyle.java │ ├── RecursiveToStringStyle.java │ ├── Reflection.java │ ├── ReflectionDiffBuilder.java │ ├── ReflectionToStringBuilder.java │ ├── StandardToStringStyle.java │ ├── ToStringBuilder.java │ ├── ToStringExclude.java │ ├── ToStringStyle.java │ ├── ToStringSummary.java │ └── package-info.java │ ├── compare │ ├── ComparableUtils.java │ ├── ObjectToStringComparator.java │ └── package-info.java │ ├── concurrent │ ├── AbstractCircuitBreaker.java │ ├── AbstractConcurrentInitializer.java │ ├── AbstractFutureProxy.java │ ├── AtomicInitializer.java │ ├── AtomicSafeInitializer.java │ ├── BackgroundInitializer.java │ ├── BasicThreadFactory.java │ ├── CallableBackgroundInitializer.java │ ├── CircuitBreaker.java │ ├── CircuitBreakingException.java │ ├── Computable.java │ ├── ConcurrentException.java │ ├── ConcurrentInitializer.java │ ├── ConcurrentRuntimeException.java │ ├── ConcurrentUtils.java │ ├── ConstantInitializer.java │ ├── EventCountCircuitBreaker.java │ ├── FutureTasks.java │ ├── LazyInitializer.java │ ├── Memoizer.java │ ├── MultiBackgroundInitializer.java │ ├── ThresholdCircuitBreaker.java │ ├── TimedSemaphore.java │ ├── UncheckedExecutionException.java │ ├── UncheckedFuture.java │ ├── UncheckedFutureImpl.java │ ├── UncheckedTimeoutException.java │ ├── locks │ │ ├── LockingVisitors.java │ │ └── package-info.java │ └── package-info.java │ ├── event │ ├── EventListenerSupport.java │ ├── EventUtils.java │ └── package-info.java │ ├── exception │ ├── CloneFailedException.java │ ├── ContextedException.java │ ├── ContextedRuntimeException.java │ ├── DefaultExceptionContext.java │ ├── ExceptionContext.java │ ├── ExceptionUtils.java │ ├── UncheckedException.java │ ├── UncheckedIllegalAccessException.java │ ├── UncheckedInterruptedException.java │ ├── UncheckedReflectiveOperationException.java │ └── package-info.java │ ├── function │ ├── BooleanConsumer.java │ ├── Consumers.java │ ├── Failable.java │ ├── FailableBiConsumer.java │ ├── FailableBiFunction.java │ ├── FailableBiPredicate.java │ ├── FailableBooleanSupplier.java │ ├── FailableCallable.java │ ├── FailableConsumer.java │ ├── FailableDoubleBinaryOperator.java │ ├── FailableDoubleConsumer.java │ ├── FailableDoubleFunction.java │ ├── FailableDoublePredicate.java │ ├── FailableDoubleSupplier.java │ ├── FailableDoubleToIntFunction.java │ ├── FailableDoubleToLongFunction.java │ ├── FailableDoubleUnaryOperator.java │ ├── FailableFunction.java │ ├── FailableIntBinaryOperator.java │ ├── FailableIntConsumer.java │ ├── FailableIntFunction.java │ ├── FailableIntPredicate.java │ ├── FailableIntSupplier.java │ ├── FailableIntToDoubleFunction.java │ ├── FailableIntToFloatFunction.java │ ├── FailableIntToLongFunction.java │ ├── FailableIntUnaryOperator.java │ ├── FailableLongBinaryOperator.java │ ├── FailableLongConsumer.java │ ├── FailableLongFunction.java │ ├── FailableLongPredicate.java │ ├── FailableLongSupplier.java │ ├── FailableLongToDoubleFunction.java │ ├── FailableLongToIntFunction.java │ ├── FailableLongUnaryOperator.java │ ├── FailableObjDoubleConsumer.java │ ├── FailableObjIntConsumer.java │ ├── FailableObjLongConsumer.java │ ├── FailablePredicate.java │ ├── FailableRunnable.java │ ├── FailableShortSupplier.java │ ├── FailableSupplier.java │ ├── FailableToBooleanFunction.java │ ├── FailableToDoubleBiFunction.java │ ├── FailableToDoubleFunction.java │ ├── FailableToIntBiFunction.java │ ├── FailableToIntFunction.java │ ├── FailableToLongBiFunction.java │ ├── FailableToLongFunction.java │ ├── Functions.java │ ├── IntToCharFunction.java │ ├── MethodInvokers.java │ ├── Predicates.java │ ├── Suppliers.java │ ├── ToBooleanBiFunction.java │ ├── TriConsumer.java │ ├── TriFunction.java │ └── package-info.java │ ├── math │ ├── Fraction.java │ ├── IEEE754rUtils.java │ ├── NumberUtils.java │ └── package-info.java │ ├── mutable │ ├── Mutable.java │ ├── MutableBoolean.java │ ├── MutableByte.java │ ├── MutableDouble.java │ ├── MutableFloat.java │ ├── MutableInt.java │ ├── MutableLong.java │ ├── MutableObject.java │ ├── MutableShort.java │ └── package-info.java │ ├── package-info.java │ ├── reflect │ ├── ConstructorUtils.java │ ├── FieldUtils.java │ ├── InheritanceUtils.java │ ├── MemberUtils.java │ ├── MethodUtils.java │ ├── TypeLiteral.java │ ├── TypeUtils.java │ ├── Typed.java │ └── package-info.java │ ├── stream │ ├── IntStreams.java │ ├── LangCollectors.java │ ├── Streams.java │ └── package-info.java │ ├── text │ ├── CompositeFormat.java │ ├── ExtendedMessageFormat.java │ ├── FormatFactory.java │ ├── FormattableUtils.java │ ├── StrBuilder.java │ ├── StrLookup.java │ ├── StrMatcher.java │ ├── StrSubstitutor.java │ ├── StrTokenizer.java │ ├── WordUtils.java │ ├── package-info.java │ └── translate │ │ ├── AggregateTranslator.java │ │ ├── CharSequenceTranslator.java │ │ ├── CodePointTranslator.java │ │ ├── EntityArrays.java │ │ ├── JavaUnicodeEscaper.java │ │ ├── LookupTranslator.java │ │ ├── NumericEntityEscaper.java │ │ ├── NumericEntityUnescaper.java │ │ ├── OctalUnescaper.java │ │ ├── UnicodeEscaper.java │ │ ├── UnicodeUnescaper.java │ │ ├── UnicodeUnpairedSurrogateRemover.java │ │ └── package-info.java │ ├── time │ ├── AbstractFormatCache.java │ ├── CalendarUtils.java │ ├── DateFormatUtils.java │ ├── DateParser.java │ ├── DatePrinter.java │ ├── DateUtils.java │ ├── DurationFormatUtils.java │ ├── DurationUtils.java │ ├── FastDateFormat.java │ ├── FastDateParser.java │ ├── FastDatePrinter.java │ ├── FastTimeZone.java │ ├── GmtTimeZone.java │ ├── StopWatch.java │ ├── TimeZones.java │ └── package-info.java │ ├── tuple │ ├── ImmutablePair.java │ ├── ImmutableTriple.java │ ├── MutablePair.java │ ├── MutableTriple.java │ ├── Pair.java │ ├── Triple.java │ └── package-info.java │ └── util │ ├── FluentBitSet.java │ ├── IterableStringTokenizer.java │ └── package-info.java ├── media └── logo.xcf ├── site ├── resources │ ├── .htaccess │ ├── checkstyle │ │ ├── checkstyle-suppressions.xml │ │ └── checkstyle.xml │ ├── download_lang.cgi │ ├── images │ │ └── logo.png │ ├── lang2-lang3-clirr-report.html │ ├── profile.jacoco │ └── release-notes │ │ ├── RELEASE-NOTES-1.0.1.txt │ │ ├── RELEASE-NOTES-1.0.txt │ │ ├── RELEASE-NOTES-2.0.txt │ │ ├── RELEASE-NOTES-2.1.txt │ │ ├── RELEASE-NOTES-2.2.txt │ │ ├── RELEASE-NOTES-2.3.txt │ │ ├── RELEASE-NOTES-2.4.txt │ │ ├── RELEASE-NOTES-2.5.txt │ │ ├── RELEASE-NOTES-2.6.txt │ │ ├── RELEASE-NOTES-3.0.1.txt │ │ ├── RELEASE-NOTES-3.0.txt │ │ ├── RELEASE-NOTES-3.1.txt │ │ ├── RELEASE-NOTES-3.10.txt │ │ ├── RELEASE-NOTES-3.2.1.txt │ │ ├── RELEASE-NOTES-3.2.txt │ │ ├── RELEASE-NOTES-3.3.1.txt │ │ ├── RELEASE-NOTES-3.3.2.txt │ │ ├── RELEASE-NOTES-3.3.txt │ │ ├── RELEASE-NOTES-3.4.txt │ │ ├── RELEASE-NOTES-3.5.txt │ │ ├── RELEASE-NOTES-3.6.txt │ │ ├── RELEASE-NOTES-3.7.txt │ │ ├── RELEASE-NOTES-3.8.1.txt │ │ ├── RELEASE-NOTES-3.8.txt │ │ └── RELEASE-NOTES-3.9.txt ├── site.xml └── xdoc │ ├── article2_4.xml │ ├── article2_5.xml │ ├── article3_0.xml │ ├── building.xml │ ├── developerguide.xml │ ├── download_lang.xml │ ├── index.xml │ ├── issue-tracking.xml │ ├── mail-lists.xml │ ├── proposal.xml │ ├── upgradeto2_0.xml │ ├── upgradeto2_1.xml │ ├── upgradeto2_2.xml │ ├── upgradeto2_3.xml │ ├── upgradeto2_4.xml │ ├── upgradeto2_5.xml │ ├── upgradeto2_6.xml │ ├── upgradeto3_0.xml │ └── userguide.xml └── test ├── java └── org │ └── apache │ └── commons │ └── lang3 │ ├── AbstractLangTest.java │ ├── AnnotationUtilsTest.java │ ├── AppendableJoinerTest.java │ ├── ArchUtilsTest.java │ ├── ArrayFillTest.java │ ├── ArraySorterTest.java │ ├── ArrayUtilsAddTest.java │ ├── ArrayUtilsInsertTest.java │ ├── ArrayUtilsRemoveMultipleTest.java │ ├── ArrayUtilsRemoveTest.java │ ├── ArrayUtilsSetTest.java │ ├── ArrayUtilsTest.java │ ├── BitFieldTest.java │ ├── BooleanUtilsTest.java │ ├── CachedRandomBitsTest.java │ ├── CharEncodingTest.java │ ├── CharRangeTest.java │ ├── CharSequenceUtilsTest.java │ ├── CharSetTest.java │ ├── CharSetUtilsTest.java │ ├── CharUtilsPerfRun.java │ ├── CharUtilsTest.java │ ├── CharsetsTest.java │ ├── ClassLoaderUtilsTest.java │ ├── ClassPathUtilsTest.java │ ├── ClassUtilsOssFuzzTest.java │ ├── ClassUtilsTest.java │ ├── ConversionTest.java │ ├── DoubleRangeTest.java │ ├── EnumUtilsTest.java │ ├── FunctionsTest.java │ ├── HashSetvBitSetTest.java │ ├── IntegerRangeTest.java │ ├── JavaVersionTest.java │ ├── LocaleUtilsTest.java │ ├── LongRangeTest.java │ ├── NotImplementedExceptionTest.java │ ├── ObjectToStringRuntimeException.java │ ├── ObjectUtilsTest.java │ ├── RandomStringUtilsTest.java │ ├── RandomUtilsTest.java │ ├── RangeTest.java │ ├── RegExUtilsTest.java │ ├── RuntimeEnvironmentTest.java │ ├── SerializationUtilsTest.java │ ├── StreamsTest.java │ ├── StringEscapeUtilsTest.java │ ├── StringUtilsAbbreviateTest.java │ ├── StringUtilsContainsTest.java │ ├── StringUtilsEmptyBlankTest.java │ ├── StringUtilsEqualsIndexOfTest.java │ ├── StringUtilsIsMixedCaseTest.java │ ├── StringUtilsIsTest.java │ ├── StringUtilsStartsEndsWithTest.java │ ├── StringUtilsSubstringTest.java │ ├── StringUtilsTest.java │ ├── StringUtilsTrimStripTest.java │ ├── StringUtilsValueOfTest.java │ ├── StringsTest.java │ ├── Supplementary.java │ ├── SystemPropertiesTest.java │ ├── SystemUtilsTest.java │ ├── ThreadUtilsTest.java │ ├── ValidateTest.java │ ├── builder │ ├── CompareToBuilderTest.java │ ├── ConversionTest.java │ ├── DefaultToStringStyleTest.java │ ├── DiffBuilderTest.java │ ├── DiffResultTest.java │ ├── DiffTest.java │ ├── EqualsBuilderReflectJreImplementationTest.java │ ├── EqualsBuilderTest.java │ ├── HashCodeBuilderAndEqualsBuilderTest.java │ ├── HashCodeBuilderTest.java │ ├── IDKeyTest.java │ ├── JsonToStringStyleTest.java │ ├── MultiLineToStringStyleTest.java │ ├── MultilineRecursiveToStringStyleTest.java │ ├── NoClassNameToStringStyleTest.java │ ├── NoFieldNamesToStringStyleTest.java │ ├── RecursiveToStringStyleTest.java │ ├── ReflectionDiffBuilderTest.java │ ├── ReflectionToStringBuilderConcurrencyTest.java │ ├── ReflectionToStringBuilderCustomImplementationTest.java │ ├── ReflectionToStringBuilderExcludeNullValuesTest.java │ ├── ReflectionToStringBuilderExcludeTest.java │ ├── ReflectionToStringBuilderExcludeWithAnnotationTest.java │ ├── ReflectionToStringBuilderIncludeTest.java │ ├── ReflectionToStringBuilderMutateInspectConcurrencyTest.java │ ├── ReflectionToStringBuilderSummaryTest.java │ ├── ReflectionToStringBuilderTest.java │ ├── ShortPrefixToStringStyleTest.java │ ├── SimpleToStringStyleTest.java │ ├── StandardToStringStyleTest.java │ ├── TestClassBuilder.java │ ├── ToStringBuilderTest.java │ ├── ToStringStyleConcurrencyTest.java │ └── ToStringStyleTest.java │ ├── compare │ ├── ComparableUtilsTest.java │ └── ObjectToStringComparatorTest.java │ ├── concurrent │ ├── AbstractConcurrentInitializerCloseAndExceptionsTest.java │ ├── AbstractConcurrentInitializerTest.java │ ├── AtomicInitializerNonObjectTest.java │ ├── AtomicInitializerObjectTest.java │ ├── AtomicInitializerSupplierTest.java │ ├── AtomicSafeInitializerSupplierTest.java │ ├── AtomicSafeInitializerTest.java │ ├── BackgroundInitializerSupplierTest.java │ ├── BackgroundInitializerTest.java │ ├── BasicThreadFactoryTest.java │ ├── CallableBackgroundInitializerTest.java │ ├── CircuitBreakingExceptionTest.java │ ├── ConcurrentUtilsTest.java │ ├── ConstantInitializerTest.java │ ├── EventCountCircuitBreakerTest.java │ ├── FutureTasksTest.java │ ├── LazyInitializerAnonClassTest.java │ ├── LazyInitializerCloserTest.java │ ├── LazyInitializerFailableCloserTest.java │ ├── LazyInitializerSimpleTest.java │ ├── LazyInitializerSingleInstanceTest.java │ ├── LazyInitializerSupplierTest.java │ ├── MemoizerComputableTest.java │ ├── MemoizerFunctionTest.java │ ├── MultiBackgroundInitializerSupplierTest.java │ ├── MultiBackgroundInitializerTest.java │ ├── ThresholdCircuitBreakerTest.java │ ├── TimedSemaphoreTest.java │ ├── UncheckedExecutionExceptionTest.java │ ├── UncheckedFutureTest.java │ ├── UncheckedTimeoutExceptionTest.java │ └── locks │ │ └── LockingVisitorsTest.java │ ├── event │ ├── EventListenerSupportTest.java │ └── EventUtilsTest.java │ ├── exception │ ├── AbstractExceptionContextTest.java │ ├── AbstractExceptionTest.java │ ├── CloneFailedExceptionTest.java │ ├── ContextedExceptionTest.java │ ├── ContextedRuntimeExceptionTest.java │ ├── CustomCheckedException.java │ ├── CustomUncheckedException.java │ ├── DefaultExceptionContextTest.java │ ├── ExceptionUtilsTest.java │ ├── UncheckedExceptionTest.java │ ├── UncheckedIllegalAccessExceptionTest.java │ ├── UncheckedInterruptedExceptionTest.java │ └── UncheckedReflectiveOperationExceptionTest.java │ ├── function │ ├── AnnotationTestFixture.java │ ├── BooleanConsumerTest.java │ ├── ConsumersTest.java │ ├── FailableFunctionsTest.java │ ├── FailableSupplierTest.java │ ├── FunctionsTest.java │ ├── IntToCharFunctionTest.java │ ├── MethodFixtures.java │ ├── MethodInvokersBiConsumerTest.java │ ├── MethodInvokersBiFunctionTest.java │ ├── MethodInvokersFailableBiConsumerTest.java │ ├── MethodInvokersFailableBiFunctionTest.java │ ├── MethodInvokersFailableFunctionTest.java │ ├── MethodInvokersFailableSupplierTest.java │ ├── MethodInvokersFunctionTest.java │ ├── MethodInvokersSupplierTest.java │ ├── Objects.java │ ├── ObjectsTest.java │ ├── PredicatesTest.java │ ├── SuppliersTest.java │ ├── ToBooleanBiFunctionTest.java │ ├── TriConsumerTest.java │ └── TriFunctionTest.java │ ├── math │ ├── FractionTest.java │ ├── IEEE754rUtilsTest.java │ └── NumberUtilsTest.java │ ├── mutable │ ├── MutableBooleanTest.java │ ├── MutableByteTest.java │ ├── MutableDoubleTest.java │ ├── MutableFloatTest.java │ ├── MutableIntTest.java │ ├── MutableLongTest.java │ ├── MutableObjectTest.java │ ├── MutableShortTest.java │ └── PrintAtomicVsMutable.java │ ├── reflect │ ├── ConstructorUtilsTest.java │ ├── FieldUtilsTest.java │ ├── InheritanceUtilsTest.java │ ├── Lang1703Test.java │ ├── MethodUtilsTest.java │ ├── TypeLiteralTest.java │ ├── TypeUtilsTest.java │ └── testbed │ │ ├── Ambig.java │ │ ├── Annotated.java │ │ ├── AnotherChild.java │ │ ├── AnotherParent.java │ │ ├── Bar.java │ │ ├── Foo.java │ │ ├── GenericConsumer.java │ │ ├── GenericParent.java │ │ ├── GenericTypeHolder.java │ │ ├── Grandchild.java │ │ ├── Parent.java │ │ ├── PrivatelyShadowedChild.java │ │ ├── PublicChild.java │ │ ├── PubliclyShadowedChild.java │ │ ├── StaticContainer.java │ │ ├── StaticContainerChild.java │ │ └── StringParameterizedChild.java │ ├── stream │ ├── FailableStreamTest.java │ ├── IntStreamsTest.java │ ├── LangCollectorsTest.java │ └── StreamsTest.java │ ├── test │ └── NotVisibleExceptionFactory.java │ ├── text │ ├── CompositeFormatTest.java │ ├── ExtendedMessageFormatTest.java │ ├── FormattableUtilsTest.java │ ├── StrBuilderAppendInsertTest.java │ ├── StrBuilderTest.java │ ├── StrLookupTest.java │ ├── StrMatcherTest.java │ ├── StrSubstitutorTest.java │ ├── StrTokenizerTest.java │ ├── WordUtilsTest.java │ └── translate │ │ ├── EntityArraysTest.java │ │ ├── LookupTranslatorTest.java │ │ ├── NumericEntityEscaperTest.java │ │ ├── NumericEntityUnescaperTest.java │ │ ├── OctalUnescaperTest.java │ │ ├── UnicodeEscaperTest.java │ │ ├── UnicodeUnescaperTest.java │ │ └── UnicodeUnpairedSurrogateRemoverTest.java │ ├── time │ ├── CalendarUtilsTest.java │ ├── DateFormatUtilsTest.java │ ├── DateUtilsFragmentTest.java │ ├── DateUtilsRoundingTest.java │ ├── DateUtilsTest.java │ ├── DurationFormatUtilsTest.java │ ├── DurationUtilsTest.java │ ├── FastDateFormatTest.java │ ├── FastDateFormat_PrinterTest.java │ ├── FastDateParserSDFTest.java │ ├── FastDateParserTest.java │ ├── FastDateParser_MoreOrLessTest.java │ ├── FastDateParser_TimeZoneStrategyTest.java │ ├── FastDatePrinterTest.java │ ├── FastDatePrinterTimeZonesTest.java │ ├── FastTimeZoneTest.java │ ├── GmtTimeZoneTest.java │ ├── Java15BugFastDateParserTest.java │ ├── StopWatchTest.java │ ├── TimeZonesTest.java │ └── WeekYearTest.java │ ├── tuple │ ├── ImmutablePairTest.java │ ├── ImmutableTripleTest.java │ ├── MutablePairTest.java │ ├── MutableTripleTest.java │ ├── PairTest.java │ └── TripleTest.java │ └── util │ ├── FluentBitSetTest.java │ └── IterableStringTokenizerTest.java └── resources ├── java.policy └── lang-708-input.txt /.asf.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | github: 17 | description: "Apache Commons Lang" 18 | homepage: https://commons.apache.org/lang/ 19 | 20 | notifications: 21 | commits: commits@commons.apache.org 22 | issues: issues@commons.apache.org 23 | pullrequests: issues@commons.apache.org 24 | jira_options: link label 25 | jobs: notifications@commons.apache.org 26 | issues_bot_dependabot: notifications@commons.apache.org 27 | pullrequests_bot_dependabot: notifications@commons.apache.org 28 | issues_bot_codecov-commenter: notifications@commons.apache.org 29 | pullrequests_bot_codecov-commenter: notifications@commons.apache.org 30 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # Auto detect text files and perform LF normalization 18 | * text=auto 19 | 20 | *.java text diff=java 21 | *.html text diff=html 22 | *.css text 23 | *.js text 24 | *.sql text 25 | -------------------------------------------------------------------------------- /.github/GH-ROBOTS.txt: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Keeps on creating FUD PRs in test code 17 | # Does not follow Apache disclosure policies 18 | User-agent: JLLeitschuh/security-research 19 | Disallow: * 20 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | version: 2 17 | updates: 18 | - package-ecosystem: "maven" 19 | directory: "/" 20 | schedule: 21 | interval: "weekly" 22 | day: "friday" 23 | - package-ecosystem: "github-actions" 24 | directory: "/" 25 | schedule: 26 | interval: "weekly" 27 | day: "friday" 28 | 29 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 19 | 20 | Thanks for your contribution to [Apache Commons](https://commons.apache.org/)! Your help is appreciated! 21 | 22 | Before you push a pull request, review this list: 23 | 24 | - [ ] Read the [contribution guidelines](CONTRIBUTING.md) for this project. 25 | - [ ] Run a successful build using the default [Maven](https://maven.apache.org/) goal with `mvn`; that's `mvn` on the command line by itself. 26 | - [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible but is a best-practice. 27 | - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. 28 | - [ ] Each commit in the pull request should have a meaningful subject line and body. Note that commits might be squashed by a maintainer on merge. 29 | -------------------------------------------------------------------------------- /.github/workflows/dependency-review.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | name: 'Dependency Review' 19 | on: [pull_request] 20 | 21 | permissions: 22 | contents: read 23 | 24 | jobs: 25 | dependency-review: 26 | runs-on: ubuntu-latest 27 | steps: 28 | - name: 'Checkout Repository' 29 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 30 | - name: 'Dependency Review PR' 31 | uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Maven build files 2 | target 3 | *.log 4 | maven-eclipse.xml 5 | build.properties 6 | site-content 7 | *~ 8 | 9 | # IntelliJ IDEA files 10 | .idea 11 | .iws 12 | *.iml 13 | *.ipr 14 | 15 | # Eclipse files 16 | .settings 17 | .classpath 18 | .project 19 | .externalToolBuilders 20 | .checkstyle 21 | 22 | # jenv's version file 23 | .java-version 24 | -------------------------------------------------------------------------------- /.mvn/.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Empty file (Maven 4 wants the directory .mvn to be present, 3 | # and we want Git to create it.) 4 | # 5 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 17 | The Apache code of conduct page is [https://www.apache.org/foundation/policies/conduct.html](https://www.apache.org/foundation/policies/conduct.html). 18 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Apache Commons Lang 2 | Copyright 2001-2025 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (https://www.apache.org/). 6 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 17 | The Apache Commons security page is [https://commons.apache.org/security.html](https://commons.apache.org/security.html). 18 | -------------------------------------------------------------------------------- /src/assembly/bin.xml: -------------------------------------------------------------------------------- 1 | 17 | 20 | bin 21 | 22 | tar.gz 23 | zip 24 | 25 | false 26 | 27 | 28 | 29 | LICENSE.txt 30 | NOTICE.txt 31 | RELEASE-NOTES.txt 32 | README.md 33 | CONTRIBUTING.md 34 | 35 | 36 | 37 | target 38 | 39 | 40 | *.jar 41 | 42 | 644 43 | 44 | 45 | target/site/apidocs 46 | apidocs 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/assembly/src.xml: -------------------------------------------------------------------------------- 1 | 17 | 20 | src 21 | 22 | tar.gz 23 | zip 24 | 25 | ${project.artifactId}-${commons.release.version}-src 26 | 27 | 28 | 29 | .travis.yml 30 | checkstyle.xml 31 | checkstyle-suppressions.xml 32 | spotbugs-exclude-filter.xml 33 | LICENSE.txt 34 | NOTICE.txt 35 | pom.xml 36 | PROPOSAL.html 37 | RELEASE-NOTES.txt 38 | README.md 39 | CONTRIBUTING.md 40 | 41 | 42 | 43 | src 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/conf/checkstyle/import-control.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/conf/pmd-exclude.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # We have ThreadGroup utilities 17 | org.apache.commons.lang3.ThreadUtils = AvoidThreadGroup 18 | 19 | # TODO? 20 | # violation beginline="2900" endline="2900" begincolumn="13" endcolumn="21" rule="AvoidBranchingStatementAsLastInLoop" ruleset="Error Prone" package="org.apache.commons.lang3" class="StringUtils" method="indexOfAnyBut" 21 | org.apache.commons.lang3.StringUtils = AvoidBranchingStatementAsLastInLoop 22 | 23 | # Bug in PMD when the same class name exists in different packages 24 | # Unnecessary use of fully qualified name 'org.apache.commons.lang3.function.FailableRunnable' due to existing same package import 'org.apache.commons.lang3.*' 25 | org.apache.commons.lang3.Functions = UnnecessaryFullyQualifiedName 26 | -------------------------------------------------------------------------------- /src/conf/pmd-ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | Excludes from default PMD rules. 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/NumberRange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3; 19 | 20 | import java.util.Comparator; 21 | 22 | /** 23 | * Specializes {@link Range} for {@link Number}s. 24 | *

25 | * We only offer specializations for Integer, Long, and Double (like Java Streams). 26 | *

27 | * 28 | * @param The Number class. 29 | * @since 3.13.0 30 | */ 31 | public class NumberRange extends Range { 32 | 33 | private static final long serialVersionUID = 1L; 34 | 35 | /** 36 | * Creates an instance. 37 | * 38 | * @param number1 the first element, not null 39 | * @param number2 the second element, not null 40 | * @param comp the comparator to be used, null for natural ordering 41 | * @throws NullPointerException when element1 is null. 42 | * @throws NullPointerException when element2 is null. 43 | */ 44 | public NumberRange(final N number1, final N number2, final Comparator comp) { 45 | super(number1, number2, comp); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/arch/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides classes to work with the values of the os.arch system property. 20 | * @since 3.6 21 | */ 22 | package org.apache.commons.lang3.arch; 23 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/builder/AbstractSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.builder; 19 | 20 | import org.apache.commons.lang3.function.FailableSupplier; 21 | 22 | /** 23 | * Abstracts supplying an instance of {@code T}. Use to implement the builder pattern. 24 | * 25 | * @param The type of results supplied by this supplier. 26 | * @param the type of builder. 27 | * @param The kind of thrown exception or error. 28 | * @since 3.14.0 29 | */ 30 | public abstract class AbstractSupplier, E extends Throwable> implements FailableSupplier { 31 | 32 | /** 33 | * Constructs a new instance. 34 | */ 35 | public AbstractSupplier() { 36 | // empty 37 | } 38 | 39 | /** 40 | * Returns this instance typed as the subclass type {@code B}. 41 | *

42 | * This is the same as the expression: 43 | *

44 | *
45 |      * (B) this
46 |      * 
47 | * 48 | * @return this instance typed as the subclass type {@code B}. 49 | */ 50 | @SuppressWarnings("unchecked") 51 | protected B asThis() { 52 | return (B) this; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/builder/DiffExclude.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.builder; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Excludes a field from being used by the {@link ReflectionDiffBuilder}. 27 | * 28 | * @since 3.13.0 29 | */ 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target(ElementType.FIELD) 32 | public @interface DiffExclude { 33 | // empty 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/builder/EqualsExclude.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.builder; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Excludes a field from being used by the various {@code reflectionEquals} methods defined on {@link EqualsBuilder}. 27 | * 28 | * @since 3.5 29 | */ 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target(ElementType.FIELD) 32 | public @interface EqualsExclude { 33 | // empty 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/builder/HashCodeExclude.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.builder; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Exclude a field from being used by the various {@code reflectionHashcode} methods defined on {@link HashCodeBuilder}. 27 | * 28 | * @since 3.5 29 | */ 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target(ElementType.FIELD) 32 | public @interface HashCodeExclude { 33 | // empty 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/builder/Reflection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.builder; 19 | 20 | import java.lang.reflect.Field; 21 | import java.util.Objects; 22 | 23 | /** 24 | * Package-private reflection code. 25 | */ 26 | final class Reflection { 27 | 28 | /** 29 | * Delegates to {@link Field#get(Object)} and rethrows {@link IllegalAccessException} as {@link IllegalArgumentException}. 30 | * 31 | * @param field The receiver of the get call. 32 | * @param obj The argument of the get call. 33 | * @return The result of the get call. 34 | * @throws IllegalArgumentException Thrown after catching {@link IllegalAccessException}. 35 | */ 36 | static Object getUnchecked(final Field field, final Object obj) { 37 | try { 38 | return Objects.requireNonNull(field, "field").get(obj); 39 | } catch (final IllegalAccessException e) { 40 | throw new IllegalArgumentException(e); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/builder/ToStringExclude.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.builder; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Excludes a field from being used by the {@link ReflectionToStringBuilder}. 27 | * 28 | * @since 3.5 29 | */ 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target(ElementType.FIELD) 32 | public @interface ToStringExclude { 33 | // empty 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/builder/ToStringSummary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.builder; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Use this annotation on the fields to get the summary instead of the detailed 27 | * information when using {@link ReflectionToStringBuilder}. 28 | * 29 | *

30 | * Notice that not all {@link ToStringStyle} implementations support the 31 | * appendSummary method. 32 | *

33 | * 34 | * @since 3.8 35 | */ 36 | @Retention(RetentionPolicy.RUNTIME) 37 | @Target(ElementType.FIELD) 38 | public @interface ToStringSummary { 39 | // empty 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/builder/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides classes to create consistent {@code equals(Object)}, {@code toString()}, {@code hashCode()}, and {@code compareTo(Object)} methods. 20 | * These classes are not thread-safe. 21 | * 22 | *

When you write a {@link Object#hashCode() hashCode()}, do you check Bloch's Effective Java? No? 23 | * You just hack in a quick number? 24 | * Well {@link org.apache.commons.lang3.builder.HashCodeBuilder} will save your day. 25 | * It, and its buddies ({@link org.apache.commons.lang3.builder.EqualsBuilder}, {@link org.apache.commons.lang3.builder.CompareToBuilder}, {@link org.apache.commons.lang3.builder.ToStringBuilder}), take care of the nasty bits while you focus on the important bits, like which fields will go into making up the hash code.

26 | * 27 | * @see Object#equals(Object) 28 | * @see Object#toString() 29 | * @see Object#hashCode() 30 | * @see Comparable#compareTo(Object) 31 | * @since 1.0 32 | */ 33 | package org.apache.commons.lang3.builder; 34 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/compare/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides classes to work with the {@link Comparable} and {@link java.util.Comparator} interfaces. 20 | * 21 | * @since 3.10 22 | */ 23 | package org.apache.commons.lang3.compare; 24 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/concurrent/Computable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.concurrent; 18 | 19 | import org.apache.commons.lang3.function.FailableFunction; 20 | 21 | /** 22 | * Definition of an interface for a wrapper around a calculation that takes a single parameter and returns a result. 23 | * 24 | *

This interface allows for wrapping a calculation into a class so that it maybe passed around an application.

25 | * 26 | *

See also {@code FailableFunction}.

27 | * 28 | * @param the type of the input to the calculation 29 | * @param the type of the output of the calculation 30 | * @see FailableFunction 31 | * @since 3.6 32 | */ 33 | @FunctionalInterface 34 | public interface Computable { 35 | 36 | /** 37 | * This method carries out the given operation with the provided argument. 38 | * 39 | * @param arg 40 | * the argument for the calculation 41 | * @return the result of the calculation 42 | * @throws InterruptedException 43 | * thrown if the calculation is interrupted 44 | */ 45 | O compute(I arg) throws InterruptedException; 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/concurrent/FutureTasks.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.concurrent; 18 | 19 | import java.util.concurrent.Callable; 20 | import java.util.concurrent.FutureTask; 21 | 22 | /** 23 | * Consists of utility methods that work with {@link FutureTask}. 24 | * 25 | * @since 3.13.0 26 | */ 27 | public class FutureTasks { 28 | 29 | /** 30 | * Creates a {@link FutureTask} and runs the given {@link Callable}. 31 | * 32 | * @param The result type returned by this FutureTask's {@code get} methods. 33 | * @param callable the Callable task. 34 | * @return a new FutureTask. 35 | */ 36 | public static FutureTask run(final Callable callable) { 37 | final FutureTask futureTask = new FutureTask<>(callable); 38 | futureTask.run(); 39 | return futureTask; 40 | } 41 | 42 | private FutureTasks() { 43 | // No instances needed. 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/concurrent/UncheckedExecutionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.concurrent; 18 | 19 | import java.util.concurrent.ExecutionException; 20 | 21 | import org.apache.commons.lang3.exception.UncheckedException; 22 | 23 | /** 24 | * Unchecked {@link ExecutionException}. 25 | * 26 | * @since 3.13.0 27 | */ 28 | public class UncheckedExecutionException extends UncheckedException { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | /** 33 | * Constructs an instance initialized to the given {@code cause}. 34 | * 35 | * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value 36 | * is permitted, and indicates that the cause is nonexistent or unknown.) 37 | */ 38 | public UncheckedExecutionException(final Throwable cause) { 39 | super(cause); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/concurrent/UncheckedTimeoutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.concurrent; 18 | 19 | import java.util.concurrent.TimeoutException; 20 | 21 | import org.apache.commons.lang3.exception.UncheckedException; 22 | 23 | /** 24 | * Unchecked {@link TimeoutException}. 25 | * 26 | * @since 3.13.0 27 | */ 28 | public class UncheckedTimeoutException extends UncheckedException { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | /** 33 | * Constructs an instance initialized to the given {@code cause}. 34 | * 35 | * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value 36 | * is permitted, and indicates that the cause is nonexistent or unknown.) 37 | */ 38 | public UncheckedTimeoutException(final Throwable cause) { 39 | super(cause); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/concurrent/locks/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides support classes for multi-threaded programming. This package is intended to be an extension to 20 | * {@link java.util.concurrent.locks}. 21 | * 22 | * @since 3.11 23 | */ 24 | package org.apache.commons.lang3.concurrent.locks; 25 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/event/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides some useful event-based utilities. 20 | * 21 | * @since 3.0 22 | */ 23 | package org.apache.commons.lang3.event; 24 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/exception/CloneFailedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.exception; 18 | 19 | /** 20 | * Exception thrown when a clone cannot be created. In contrast to 21 | * {@link CloneNotSupportedException} this is a {@link RuntimeException}. 22 | * 23 | * @since 3.0 24 | */ 25 | public class CloneFailedException extends RuntimeException { 26 | 27 | private static final long serialVersionUID = 20091223L; 28 | 29 | /** 30 | * Constructs a CloneFailedException. 31 | * 32 | * @param message description of the exception 33 | */ 34 | public CloneFailedException(final String message) { 35 | super(message); 36 | } 37 | 38 | /** 39 | * Constructs a CloneFailedException. 40 | * 41 | * @param message description of the exception 42 | * @param cause cause of the exception 43 | */ 44 | public CloneFailedException(final String message, final Throwable cause) { 45 | super(message, cause); 46 | } 47 | 48 | /** 49 | * Constructs a CloneFailedException. 50 | * 51 | * @param cause cause of the exception 52 | */ 53 | public CloneFailedException(final Throwable cause) { 54 | super(cause); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/exception/UncheckedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.exception; 18 | 19 | /** 20 | * Abstracts the concept of wrapping a checked exception as unchecked. 21 | *

22 | * Subclasses should only be used to wrap checked exception. 23 | *

24 | * 25 | * @since 3.13.0 26 | */ 27 | public class UncheckedException extends RuntimeException { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | /** 32 | * Constructs an instance initialized to the given {@code cause}. 33 | * 34 | * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value 35 | * is permitted, and indicates that the cause is nonexistent or unknown.) 36 | */ 37 | public UncheckedException(final Throwable cause) { 38 | super(cause); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/exception/UncheckedIllegalAccessException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.exception; 19 | 20 | /** 21 | * Unchecked {@link IllegalAccessException}. 22 | * 23 | * @since 3.13.0 24 | */ 25 | public class UncheckedIllegalAccessException extends UncheckedReflectiveOperationException { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | /** 30 | * Constructs an instance initialized to the given {@code cause}. 31 | * 32 | * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value 33 | * is permitted, and indicates that the cause is nonexistent or unknown.) 34 | */ 35 | public UncheckedIllegalAccessException(final Throwable cause) { 36 | super(cause); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/exception/UncheckedInterruptedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.exception; 18 | 19 | /** 20 | * Unchecked {@link InterruptedException}. 21 | * 22 | * @since 3.13.0 23 | */ 24 | public class UncheckedInterruptedException extends UncheckedException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructs an instance initialized to the given {@code cause}. 30 | * 31 | * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value 32 | * is permitted, and indicates that the cause is nonexistent or unknown.) 33 | */ 34 | public UncheckedInterruptedException(final Throwable cause) { 35 | super(cause); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/exception/UncheckedReflectiveOperationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.exception; 18 | 19 | /** 20 | * Unchecked {@link ReflectiveOperationException}. 21 | * 22 | * @since 3.13.0 23 | */ 24 | public class UncheckedReflectiveOperationException extends UncheckedException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructs an instance initialized to the given {@code cause}. 30 | * 31 | * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value 32 | * is permitted, and indicates that the cause is nonexistent or unknown.) 33 | */ 34 | public UncheckedReflectiveOperationException(final Throwable cause) { 35 | super(cause); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides functionality for Exceptions. 20 | *

Contains the concept of an exception with context i.e. such an exception will contain a map with keys and values. 21 | * This provides an easy way to pass valuable state information at exception time in useful form to a calling process.

22 | *

Lastly, {@link org.apache.commons.lang3.exception.ExceptionUtils} also contains {@link Throwable} manipulation 23 | * and examination routines.

24 | * 25 | * @since 1.0 26 | */ 27 | package org.apache.commons.lang3.exception; 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableBooleanSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.BooleanSupplier; 21 | 22 | /** 23 | * A functional interface like {@link BooleanSupplier} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableBooleanSupplier { 30 | 31 | /** 32 | * Supplies a boolean. 33 | * 34 | * @return a result 35 | * @throws E if the supplier fails 36 | */ 37 | boolean getAsBoolean() throws E; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableCallable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | /** 21 | * A functional interface like {@link java.util.concurrent.Callable} that declares a {@link Throwable}. 22 | * 23 | * @param Return type. 24 | * @param The kind of thrown exception or error. 25 | * @since 3.11 26 | */ 27 | @FunctionalInterface 28 | public interface FailableCallable { 29 | 30 | /** 31 | * Calls the callable. 32 | * 33 | * @return The value returned from the callable 34 | * @throws E if the callable fails 35 | */ 36 | R call() throws E; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableDoubleBinaryOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.DoubleBinaryOperator; 21 | 22 | /** 23 | * A functional interface like {@link DoubleBinaryOperator} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableDoubleBinaryOperator { 30 | 31 | /** 32 | * Applies this operator to the given operands. 33 | * 34 | * @param left the first operand 35 | * @param right the second operand 36 | * @return the operator result 37 | * @throws E if the operation fails 38 | */ 39 | double applyAsDouble(double left, double right) throws E; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableDoubleFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.DoubleFunction; 21 | 22 | /** 23 | * A functional interface like {@link DoubleFunction} that declares a {@link Throwable}. 24 | * 25 | * @param Return type. 26 | * @param The kind of thrown exception or error. 27 | * @since 3.11 28 | */ 29 | @FunctionalInterface 30 | public interface FailableDoubleFunction { 31 | 32 | /** NOP singleton */ 33 | @SuppressWarnings("rawtypes") 34 | FailableDoubleFunction NOP = t -> null; 35 | 36 | /** 37 | * Returns the NOP singleton. 38 | * 39 | * @param Return type. 40 | * @param The kind of thrown exception or error. 41 | * @return The NOP singleton. 42 | */ 43 | @SuppressWarnings("unchecked") 44 | static FailableDoubleFunction nop() { 45 | return NOP; 46 | } 47 | 48 | /** 49 | * Applies this function. 50 | * 51 | * @param input the input for the function 52 | * @return the result of the function 53 | * @throws E Thrown when the function fails. 54 | */ 55 | R apply(double input) throws E; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableDoubleSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.DoubleSupplier; 21 | 22 | /** 23 | * A functional interface like {@link DoubleSupplier} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableDoubleSupplier { 30 | 31 | /** 32 | * Supplies a double. 33 | * 34 | * @return a result 35 | * @throws E if the supplier fails 36 | */ 37 | double getAsDouble() throws E; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableDoubleToIntFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.DoubleToIntFunction; 21 | 22 | /** 23 | * A functional interface like {@link DoubleToIntFunction} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableDoubleToIntFunction { 30 | 31 | /** NOP singleton */ 32 | @SuppressWarnings("rawtypes") 33 | FailableDoubleToIntFunction NOP = t -> 0; 34 | 35 | /** 36 | * Returns the NOP singleton. 37 | * 38 | * @param The kind of thrown exception or error. 39 | * @return The NOP singleton. 40 | */ 41 | @SuppressWarnings("unchecked") 42 | static FailableDoubleToIntFunction nop() { 43 | return NOP; 44 | } 45 | 46 | /** 47 | * Applies this function to the given argument. 48 | * 49 | * @param value the function argument 50 | * @return the function result 51 | * @throws E Thrown when the function fails. 52 | */ 53 | int applyAsInt(double value) throws E; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableDoubleToLongFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.DoubleToLongFunction; 21 | 22 | /** 23 | * A functional interface like {@link DoubleToLongFunction} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableDoubleToLongFunction { 30 | 31 | /** NOP singleton */ 32 | @SuppressWarnings("rawtypes") 33 | FailableDoubleToLongFunction NOP = t -> 0; 34 | 35 | /** 36 | * Returns the NOP singleton. 37 | * 38 | * @param The kind of thrown exception or error. 39 | * @return The NOP singleton. 40 | */ 41 | @SuppressWarnings("unchecked") 42 | static FailableDoubleToLongFunction nop() { 43 | return NOP; 44 | } 45 | 46 | /** 47 | * Applies this function to the given argument. 48 | * 49 | * @param value the function argument 50 | * @return the function result 51 | * @throws E if the operation fails 52 | */ 53 | int applyAsLong(double value) throws E; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableIntBinaryOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.IntBinaryOperator; 21 | 22 | /** 23 | * A functional interface like {@link IntBinaryOperator} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableIntBinaryOperator { 30 | 31 | /** 32 | * Applies this operator to the given operands. 33 | * 34 | * @param left the first operand 35 | * @param right the second operand 36 | * @return the operator result 37 | * @throws E if the operation fails 38 | */ 39 | int applyAsInt(int left, int right) throws E; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableIntFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.IntFunction; 21 | 22 | /** 23 | * A functional interface like {@link IntFunction} that declares a {@link Throwable}. 24 | * 25 | * @param Return type. 26 | * @param The kind of thrown exception or error. 27 | * @since 3.11 28 | */ 29 | @FunctionalInterface 30 | public interface FailableIntFunction { 31 | 32 | /** NOP singleton */ 33 | @SuppressWarnings("rawtypes") 34 | FailableIntFunction NOP = t -> null; 35 | 36 | /** 37 | * Returns the NOP singleton. 38 | * 39 | * @param Return type. 40 | * @param The kind of thrown exception or error. 41 | * @return The NOP singleton. 42 | */ 43 | @SuppressWarnings("unchecked") 44 | static FailableIntFunction nop() { 45 | return NOP; 46 | } 47 | 48 | /** 49 | * Applies this function. 50 | * 51 | * @param input the input for the function 52 | * @return the result of the function 53 | * @throws E Thrown when the function fails. 54 | */ 55 | R apply(int input) throws E; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableIntSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.IntSupplier; 21 | 22 | /** 23 | * A functional interface like {@link IntSupplier} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableIntSupplier { 30 | 31 | /** 32 | * Supplies an int. 33 | * 34 | * @return a result 35 | * @throws E if the supplier fails 36 | */ 37 | int getAsInt() throws E; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableIntToDoubleFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.IntToDoubleFunction; 21 | 22 | /** 23 | * A functional interface like {@link IntToDoubleFunction} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableIntToDoubleFunction { 30 | 31 | /** NOP singleton */ 32 | @SuppressWarnings("rawtypes") 33 | FailableIntToDoubleFunction NOP = t -> 0d; 34 | 35 | /** 36 | * Returns the NOP singleton. 37 | * 38 | * @param The kind of thrown exception or error. 39 | * @return The NOP singleton. 40 | */ 41 | @SuppressWarnings("unchecked") 42 | static FailableIntToDoubleFunction nop() { 43 | return NOP; 44 | } 45 | 46 | /** 47 | * Applies this function to the given argument. 48 | * 49 | * @param value the function argument 50 | * @return the function result 51 | * @throws E Thrown when the function fails. 52 | */ 53 | double applyAsDouble(int value) throws E; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableIntToFloatFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.IntToDoubleFunction; 21 | 22 | /** 23 | * A functional interface like {@link IntToDoubleFunction} but for {@code float} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.18.0 27 | */ 28 | @FunctionalInterface 29 | public interface FailableIntToFloatFunction { 30 | 31 | /** NOP singleton */ 32 | @SuppressWarnings("rawtypes") 33 | FailableIntToFloatFunction NOP = t -> 0f; 34 | 35 | /** 36 | * Returns the NOP singleton. 37 | * 38 | * @param The kind of thrown exception or error. 39 | * @return The NOP singleton. 40 | */ 41 | @SuppressWarnings("unchecked") 42 | static FailableIntToFloatFunction nop() { 43 | return NOP; 44 | } 45 | 46 | /** 47 | * Applies this function to the given argument. 48 | * 49 | * @param value the function argument 50 | * @return the function result 51 | * @throws E Thrown when the function fails. 52 | */ 53 | float applyAsFloat(int value) throws E; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableIntToLongFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.IntToLongFunction; 21 | 22 | /** 23 | * A functional interface like {@link IntToLongFunction} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableIntToLongFunction { 30 | 31 | /** NOP singleton */ 32 | @SuppressWarnings("rawtypes") 33 | FailableIntToLongFunction NOP = t -> 0L; 34 | 35 | /** 36 | * Returns the NOP singleton. 37 | * 38 | * @param The kind of thrown exception or error. 39 | * @return The NOP singleton. 40 | */ 41 | @SuppressWarnings("unchecked") 42 | static FailableIntToLongFunction nop() { 43 | return NOP; 44 | } 45 | 46 | /** 47 | * Applies this function to the given argument. 48 | * 49 | * @param value the function argument 50 | * @return the function result 51 | * @throws E Thrown when the function fails. 52 | */ 53 | long applyAsLong(int value) throws E; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableLongBinaryOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.LongBinaryOperator; 21 | 22 | /** 23 | * A functional interface like {@link LongBinaryOperator} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableLongBinaryOperator { 30 | 31 | /** 32 | * Applies this operator to the given operands. 33 | * 34 | * @param left the first operand 35 | * @param right the second operand 36 | * @return the operator result 37 | * @throws E if the operation fails 38 | */ 39 | long applyAsLong(long left, long right) throws E; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableLongFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.LongFunction; 21 | 22 | /** 23 | * A functional interface like {@link LongFunction} that declares a {@link Throwable}. 24 | * 25 | * @param Return type. 26 | * @param The kind of thrown exception or error. 27 | * @since 3.11 28 | */ 29 | @FunctionalInterface 30 | public interface FailableLongFunction { 31 | 32 | /** NOP singleton */ 33 | @SuppressWarnings("rawtypes") 34 | FailableLongFunction NOP = t -> null; 35 | 36 | /** 37 | * Returns the NOP singleton. 38 | * 39 | * @param Return type. 40 | * @param The kind of thrown exception or error. 41 | * @return The NOP singleton. 42 | */ 43 | @SuppressWarnings("unchecked") 44 | static FailableLongFunction nop() { 45 | return NOP; 46 | } 47 | 48 | /** 49 | * Applies this function. 50 | * 51 | * @param input the input for the function 52 | * @return the result of the function 53 | * @throws E Thrown when the function fails. 54 | */ 55 | R apply(long input) throws E; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableLongSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.LongSupplier; 21 | 22 | /** 23 | * A functional interface like {@link LongSupplier} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableLongSupplier { 30 | 31 | /** 32 | * Supplies a long. 33 | * 34 | * @return a result 35 | * @throws E if the supplier fails 36 | */ 37 | long getAsLong() throws E; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableLongToDoubleFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.LongToDoubleFunction; 21 | 22 | /** 23 | * A functional interface like {@link LongToDoubleFunction} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableLongToDoubleFunction { 30 | 31 | /** NOP singleton */ 32 | @SuppressWarnings("rawtypes") 33 | FailableLongToDoubleFunction NOP = t -> 0d; 34 | 35 | /** 36 | * Returns the NOP singleton. 37 | * 38 | * @param The kind of thrown exception or error. 39 | * @return The NOP singleton. 40 | */ 41 | @SuppressWarnings("unchecked") 42 | static FailableLongToDoubleFunction nop() { 43 | return NOP; 44 | } 45 | 46 | /** 47 | * Applies this function to the given argument. 48 | * 49 | * @param value the function argument 50 | * @return the function result 51 | * @throws E Thrown when the function fails. 52 | */ 53 | double applyAsDouble(long value) throws E; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableLongToIntFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.LongToIntFunction; 21 | 22 | /** 23 | * A functional interface like {@link LongToIntFunction} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.11 27 | */ 28 | @FunctionalInterface 29 | public interface FailableLongToIntFunction { 30 | 31 | /** NOP singleton */ 32 | @SuppressWarnings("rawtypes") 33 | FailableLongToIntFunction NOP = t -> 0; 34 | 35 | /** 36 | * Returns the NOP singleton. 37 | * 38 | * @param The kind of thrown exception or error. 39 | * @return The NOP singleton. 40 | */ 41 | @SuppressWarnings("unchecked") 42 | static FailableLongToIntFunction nop() { 43 | return NOP; 44 | } 45 | 46 | /** 47 | * Applies this function to the given argument. 48 | * 49 | * @param value the function argument 50 | * @return the function result 51 | * @throws E Thrown when the function fails. 52 | */ 53 | int applyAsInt(long value) throws E; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableRunnable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | /** 21 | * A functional interface like {@link Runnable} that declares a kind of {@link Throwable}. 22 | * 23 | * @param The kind of {@link Throwable}. 24 | * @since 3.11 25 | */ 26 | @FunctionalInterface 27 | public interface FailableRunnable { 28 | 29 | /** 30 | * Runs the function. 31 | * 32 | * @throws E Thrown when the function fails. 33 | */ 34 | void run() throws E; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableShortSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.IntSupplier; 21 | 22 | /** 23 | * A functional interface like {@link IntSupplier} but for {@code short} that declares a {@link Throwable}. 24 | * 25 | * @param The kind of thrown exception or error. 26 | * @since 3.12.0 27 | */ 28 | @FunctionalInterface 29 | public interface FailableShortSupplier { 30 | 31 | /** 32 | * Supplies an int. 33 | * 34 | * @return a result 35 | * @throws E if the supplier fails 36 | */ 37 | short getAsShort() throws E; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableToBooleanFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | /** 21 | * A functional interface like a {@code ToBooleanFunction} that declares a {@link Throwable}. 22 | * 23 | * @param the type of the argument to the function 24 | * @param The kind of thrown exception or error. 25 | * @since 3.18 26 | */ 27 | @FunctionalInterface 28 | public interface FailableToBooleanFunction { 29 | 30 | /** NOP singleton */ 31 | @SuppressWarnings("rawtypes") 32 | FailableToBooleanFunction NOP = t -> false; 33 | 34 | /** 35 | * Returns the NOP singleton. 36 | * 37 | * @param the type of the argument to the function 38 | * @param The kind of thrown exception or error. 39 | * @return The NOP singleton. 40 | */ 41 | @SuppressWarnings("unchecked") 42 | static FailableToBooleanFunction nop() { 43 | return NOP; 44 | } 45 | 46 | /** 47 | * Applies this function to the given arguments. 48 | * 49 | * @param t the first function argument 50 | * @return the function result 51 | * @throws E Thrown when the function fails. 52 | */ 53 | boolean applyAsBoolean(T t) throws E; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableToDoubleFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.ToDoubleFunction; 21 | 22 | /** 23 | * A functional interface like {@link ToDoubleFunction} that declares a {@link Throwable}. 24 | * 25 | * @param the type of the argument to the function 26 | * @param The kind of thrown exception or error. 27 | * @since 3.11 28 | */ 29 | @FunctionalInterface 30 | public interface FailableToDoubleFunction { 31 | 32 | /** NOP singleton */ 33 | @SuppressWarnings("rawtypes") 34 | FailableToDoubleFunction NOP = t -> 0d; 35 | 36 | /** 37 | * Returns the NOP singleton. 38 | * 39 | * @param the type of the argument to the function 40 | * @param The kind of thrown exception or error. 41 | * @return The NOP singleton. 42 | */ 43 | @SuppressWarnings("unchecked") 44 | static FailableToDoubleFunction nop() { 45 | return NOP; 46 | } 47 | 48 | /** 49 | * Applies this function to the given arguments. 50 | * 51 | * @param t the first function argument 52 | * @return the function result 53 | * @throws E Thrown when the function fails. 54 | */ 55 | double applyAsDouble(T t) throws E; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableToIntFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.ToIntFunction; 21 | 22 | /** 23 | * A functional interface like {@link ToIntFunction} that declares a {@link Throwable}. 24 | * 25 | * @param the type of the argument to the function 26 | * @param The kind of thrown exception or error. 27 | * @since 3.11 28 | */ 29 | @FunctionalInterface 30 | public interface FailableToIntFunction { 31 | 32 | /** NOP singleton */ 33 | @SuppressWarnings("rawtypes") 34 | FailableToIntFunction NOP = t -> 0; 35 | 36 | /** 37 | * Returns the NOP singleton. 38 | * 39 | * @param the type of the argument to the function 40 | * @param The kind of thrown exception or error. 41 | * @return The NOP singleton. 42 | */ 43 | @SuppressWarnings("unchecked") 44 | static FailableToIntFunction nop() { 45 | return NOP; 46 | } 47 | 48 | /** 49 | * Applies this function to the given arguments. 50 | * 51 | * @param t the first function argument 52 | * @return the function result 53 | * @throws E Thrown when the function fails. 54 | */ 55 | int applyAsInt(T t) throws E; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/FailableToLongFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.ToLongFunction; 21 | 22 | /** 23 | * A functional interface like {@link ToLongFunction} that declares a {@link Throwable}. 24 | * 25 | * @param the type of the first argument to the function 26 | * @param The kind of thrown exception or error. 27 | * @since 3.11 28 | */ 29 | @FunctionalInterface 30 | public interface FailableToLongFunction { 31 | 32 | /** NOP singleton */ 33 | @SuppressWarnings("rawtypes") 34 | FailableToLongFunction NOP = t -> 0L; 35 | 36 | /** 37 | * Returns the NOP singleton. 38 | * 39 | * @param the type of the argument to the function 40 | * @param The kind of thrown exception or error. 41 | * @return The NOP singleton. 42 | */ 43 | @SuppressWarnings("unchecked") 44 | static FailableToLongFunction nop() { 45 | return NOP; 46 | } 47 | 48 | /** 49 | * Applies this function to the given arguments. 50 | * 51 | * @param t the first function argument 52 | * @return the function result 53 | * @throws E Thrown when the function fails. 54 | */ 55 | long applyAsLong(T t) throws E; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/IntToCharFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.Function; 21 | 22 | /** 23 | * Represents a function that accepts an int-valued argument and produces a char-valued result. This is the {@code int}-to-{@code char} primitive specialization 24 | * for {@link Function}. 25 | * 26 | *

27 | * This is a functional interface whose functional method is {@link #applyAsChar(int)}. 28 | *

29 | * 30 | * @see Function 31 | * @since 3.13.0 32 | */ 33 | @FunctionalInterface 34 | public interface IntToCharFunction { 35 | 36 | /** 37 | * Applies this function to the given argument. 38 | * 39 | * @param value the function argument. 40 | * @return the function result. 41 | */ 42 | char applyAsChar(int value); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/Predicates.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.Predicate; 21 | 22 | /** 23 | * Factory for {@link Predicate}. 24 | * 25 | * @since 3.18.0 26 | */ 27 | public class Predicates { 28 | 29 | private static final Predicate ALWAYS_TRUE = t -> true; 30 | private static final Predicate ALWAYS_FALSE = t -> false; 31 | 32 | /** 33 | * Returns the Predicate singleton that always returns false. 34 | * 35 | * @param the type of the input to the predicate. 36 | * @return the Predicate singleton. 37 | */ 38 | @SuppressWarnings("unchecked") 39 | // method name cannot be "false". 40 | public static Predicate falsePredicate() { 41 | return (Predicate) ALWAYS_FALSE; 42 | } 43 | 44 | /** 45 | * Returns the Predicate singleton that always returns true. 46 | * 47 | * @param the type of the input to the predicate. 48 | * @return the Predicate singleton. 49 | */ 50 | @SuppressWarnings("unchecked") 51 | // method name cannot be "true". 52 | public static Predicate truePredicate() { 53 | return (Predicate) ALWAYS_TRUE; 54 | } 55 | 56 | /** 57 | * No instances needed. 58 | */ 59 | private Predicates() { 60 | // empty 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/ToBooleanBiFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.util.function.BiFunction; 21 | 22 | /** 23 | * A function that accepts two arguments and produces a boolean result. This is the {@code boolean}-producing primitive 24 | * specialization for {@link BiFunction}. 25 | * 26 | * @param the type of the first argument to the function. 27 | * @param the type of the second argument to the function. 28 | * @see BiFunction 29 | * @since 3.12.0 30 | */ 31 | @FunctionalInterface 32 | public interface ToBooleanBiFunction { 33 | 34 | /** 35 | * Applies this function to the given arguments. 36 | * 37 | * @param t the first function argument. 38 | * @param u the second function argument. 39 | * @return the function result. 40 | */ 41 | boolean applyAsBoolean(T t, U u); 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/function/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides functional interfaces to complement those in {@code java.lang.function} and utilities for working with Java 20 | * 8 lambdas. 21 | * 22 | *

23 | * Contains failable functional interfaces that address the fact that lambdas are supposed not to throw Exceptions, at 24 | * least not checked Exceptions, A.K.A. instances of {@link Exception}. A failable functional interface 25 | * declares a type of Exception that may be raised if the function fails. 26 | *

27 | * 28 | * @since 3.11 29 | */ 30 | package org.apache.commons.lang3.function; 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/mutable/Mutable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.mutable; 19 | 20 | /** 21 | * Provides mutable access to a value. 22 | *

23 | * {@link Mutable} is used as a generic interface to the implementations in this package. 24 | *

25 | *

26 | * A typical use case would be to enable a primitive or string to be passed to a method and allow that method to 27 | * effectively change the value of the primitive/string. Another use case is to store a frequently changing primitive in 28 | * a collection (for example a total in a map) without needing to create new Integer/Long wrapper objects. 29 | *

30 | * 31 | * @param the type to set and get 32 | * @since 2.1 33 | */ 34 | public interface Mutable { 35 | 36 | /** 37 | * Gets the value of this mutable. 38 | * 39 | * @return the stored value 40 | */ 41 | T getValue(); 42 | 43 | /** 44 | * Sets the value of this mutable. 45 | * 46 | * @param value 47 | * the value to store 48 | * @throws NullPointerException 49 | * if the object is null and null is invalid 50 | * @throws ClassCastException 51 | * if the type is invalid 52 | */ 53 | void setValue(T value); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/mutable/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides typed mutable wrappers to primitive values and Object. 20 | * These wrappers are similar to the wrappers provided by the Java API, but allow the wrapped value to be changed without needing to create a separate wrapper object. 21 | * These classes are not thread-safe. 22 | * 23 | * @since 2.1 24 | */ 25 | package org.apache.commons.lang3.mutable; 26 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/reflect/Typed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect; 18 | 19 | import java.lang.reflect.Type; 20 | 21 | /** 22 | * Generalization of "has a type." 23 | * 24 | * @param the type 25 | * @see TypeLiteral 26 | * @since 3.2 27 | */ 28 | @FunctionalInterface 29 | public interface Typed { 30 | 31 | /** 32 | * Gets the {@link Type} represented by this entity. 33 | * 34 | * @return Type 35 | */ 36 | Type getType(); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/reflect/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides high-level uses of the {@code java.lang.reflect} APIs. 20 | *

These classes are immutable and thread-safe.

21 | * 22 | * @since 3.0 23 | */ 24 | package org.apache.commons.lang3.reflect; 25 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/stream/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides utility classes to complement those in {@link java.util.stream}. 20 | * 21 | *

Contains utilities to allow streaming of failable functional interfaces from the 22 | * {@code org.apache.commons.lang3.functions} package allowing streaming of functional expressions 23 | * that may raise an Exception. 24 | * 25 | * @since 3.11 26 | */ 27 | package org.apache.commons.lang3.stream; 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/text/FormatFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.text; 18 | 19 | import java.text.Format; 20 | import java.util.Locale; 21 | 22 | /** 23 | * Format factory. 24 | * 25 | * @since 2.4 26 | * @deprecated As of 3.6, use Apache Commons Text 27 | * 28 | * FormatFactory. 29 | */ 30 | @Deprecated 31 | public interface FormatFactory { 32 | 33 | /** 34 | * Create or retrieve a format instance. 35 | * 36 | * @param name The format type name 37 | * @param arguments Arguments used to create the format instance. This allows the 38 | * {@link FormatFactory} to implement the "format style" 39 | * concept from {@link java.text.MessageFormat}. 40 | * @param locale The locale, may be null 41 | * @return The format instance 42 | */ 43 | Format getFormat(String name, String arguments, Locale locale); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/text/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Deprecated: Provides classes for handling and manipulating text, partly as an extension to {@link java.text}. The classes in this package 20 | * are, for the most part, intended to be instantiated (i.e. they are not utility classes with lots of static methods). 21 | * 22 | *

23 | * Amongst other classes, the text package provides a replacement for {@link StringBuffer} named {@link org.apache.commons.lang3.text.StrBuilder}, a class for 24 | * substituting variables within a String named {@link org.apache.commons.lang3.text.StrSubstitutor} and a replacement for {@link java.util.StringTokenizer} 25 | * named {@link org.apache.commons.lang3.text.StrTokenizer}. While somewhat ungainly, the {@code Str} prefix has been used to ensure we don't clash with any 26 | * current or future standard Java classes. 27 | *

28 | *

29 | * Deprecated: As of 3.6, use the Apache Commons Text 30 | * text package. 31 | *

32 | * 33 | * @since 2.1 34 | */ 35 | package org.apache.commons.lang3.text; 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemover.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.text.translate; 18 | 19 | import java.io.IOException; 20 | import java.io.Writer; 21 | 22 | /** 23 | * Helper subclass to CharSequenceTranslator to remove unpaired surrogates. 24 | * 25 | * @deprecated As of 3.6, use Apache Commons Text 26 | * 27 | * UnicodeUnpairedSurrogateRemover. 28 | */ 29 | @Deprecated 30 | public class UnicodeUnpairedSurrogateRemover extends CodePointTranslator { 31 | 32 | /** 33 | * Constructs a new instance. 34 | */ 35 | public UnicodeUnpairedSurrogateRemover() { 36 | // empty 37 | } 38 | 39 | /** 40 | * Implements translate that throws out unpaired surrogates. 41 | * {@inheritDoc} 42 | */ 43 | @Override 44 | public boolean translate(final int codePoint, final Writer out) throws IOException { 45 | // true: It's a surrogate. Write nothing and say we've translated. 46 | return codePoint >= Character.MIN_SURROGATE && codePoint <= Character.MAX_SURROGATE; 47 | // It's not a surrogate. Don't translate it. 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/text/translate/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Deprecated: Provides text translation routines from a set of smaller building blocks. Initially created to make it possible for the user to 20 | * customize the rules in the StringEscapeUtils class. 21 | *

22 | * These classes are immutable, and therefore thread-safe. 23 | *

24 | *

25 | * Deprecated: As of 3.6, use the Apache Commons Text 26 | * translate package. 27 | *

28 | * 29 | * @since 3.0 30 | */ 31 | package org.apache.commons.lang3.text.translate; 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/time/TimeZones.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.time; 19 | 20 | import java.util.TimeZone; 21 | 22 | import org.apache.commons.lang3.ObjectUtils; 23 | 24 | /** 25 | * Helps to deal with {@link java.util.TimeZone}s. 26 | * 27 | * @since 3.7 28 | */ 29 | public class TimeZones { 30 | 31 | /** 32 | * A public version of {@link java.util.TimeZone}'s package private {@code GMT_ID} field. 33 | */ 34 | public static final String GMT_ID = "GMT"; 35 | 36 | /** 37 | * The GMT time zone. 38 | * 39 | * @since 3.13.0 40 | */ 41 | public static final TimeZone GMT = TimeZone.getTimeZone(GMT_ID); 42 | 43 | /** 44 | * Returns the given TimeZone if non-{@code null}, otherwise {@link TimeZone#getDefault()}. 45 | * 46 | * @param timeZone a locale or {@code null}. 47 | * @return the given locale if non-{@code null}, otherwise {@link TimeZone#getDefault()}. 48 | * @since 3.13.0 49 | */ 50 | public static TimeZone toTimeZone(final TimeZone timeZone) { 51 | return ObjectUtils.getIfNull(timeZone, TimeZone::getDefault); 52 | } 53 | 54 | /** Do not instantiate. */ 55 | private TimeZones() { 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/time/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides classes and methods to work with dates and durations. 20 | * These classes are immutable (and therefore thread-safe) apart from {@link org.apache.commons.lang3.time.StopWatch}. 21 | * 22 | *

The time package contains some basic utilities for manipulating time (a delorean, police box and grandfather clock?). 23 | * These include a {@link org.apache.commons.lang3.time.StopWatch} for simple performance measurements and an optimized {@link org.apache.commons.lang3.time.FastDateFormat} class.

24 | * 25 | * @since 2.0 26 | */ 27 | package org.apache.commons.lang3.time; 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/tuple/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides tuple classes, both mutable and immutable {@link Pair} and {@link Triple}. 20 | * 21 | * @since 3.0 22 | */ 23 | package org.apache.commons.lang3.tuple; 24 | -------------------------------------------------------------------------------- /src/main/java/org/apache/commons/lang3/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Provides classes that work with the Java {@link java.util} package. 20 | * 21 | * @since 3.13.0 22 | */ 23 | package org.apache.commons.lang3.util; 24 | -------------------------------------------------------------------------------- /src/media/logo.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/commons-lang/13aebc396de9233b8f913afa4b02f62f9d11f819/src/media/logo.xcf -------------------------------------------------------------------------------- /src/site/resources/.htaccess: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | AddCharset utf-8 .txt .html 17 | -------------------------------------------------------------------------------- /src/site/resources/checkstyle/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/site/resources/download_lang.cgi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Just call the standard mirrors.cgi script. It will use download.html 3 | # as the input template. 4 | exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $* -------------------------------------------------------------------------------- /src/site/resources/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/commons-lang/13aebc396de9233b8f913afa4b02f62f9d11f819/src/site/resources/images/logo.png -------------------------------------------------------------------------------- /src/site/resources/profile.jacoco: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // https://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | -------------------------------------------------------------------------------- /src/site/resources/release-notes/RELEASE-NOTES-3.8.1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/commons-lang/13aebc396de9233b8f913afa4b02f62f9d11f819/src/site/resources/release-notes/RELEASE-NOTES-3.8.1.txt -------------------------------------------------------------------------------- /src/site/resources/release-notes/RELEASE-NOTES-3.8.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/commons-lang/13aebc396de9233b8f913afa4b02f62f9d11f819/src/site/resources/release-notes/RELEASE-NOTES-3.8.txt -------------------------------------------------------------------------------- /src/site/resources/release-notes/RELEASE-NOTES-3.9.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/commons-lang/13aebc396de9233b8f913afa4b02f62f9d11f819/src/site/resources/release-notes/RELEASE-NOTES-3.9.txt -------------------------------------------------------------------------------- /src/site/xdoc/userguide.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 22 | 23 | Commons Lang - User guide 24 | Apache Commons Team 25 | 26 | 27 | 28 | 29 |
30 |

31 | The User Guide has moved to the package Javadoc. 32 |

33 |
34 | 35 | 36 |
37 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/AbstractLangTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertTrue; 20 | 21 | import org.apache.commons.lang3.builder.ToStringStyle; 22 | import org.junit.jupiter.api.AfterEach; 23 | 24 | /** 25 | * All tests subclass this test. 26 | */ 27 | public class AbstractLangTest { 28 | 29 | /** 30 | * All tests should leave the {@link ToStringStyle} registry empty. 31 | */ 32 | @AfterEach 33 | public void after() { 34 | assertTrue(ToStringStyle.getRegistry().isEmpty(), "Expected null, actual: " + ToStringStyle.getRegistry()); 35 | // TODO Do more to make sure memory is not retained, maybe like Log4j checks for it. 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/ObjectToStringRuntimeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3; 19 | 20 | /** 21 | * An object that throws a runtime exception when you call {@link #toString()}. 22 | */ 23 | public class ObjectToStringRuntimeException { 24 | 25 | private final String message; 26 | 27 | public ObjectToStringRuntimeException(final String message) { 28 | this.message = message; 29 | } 30 | 31 | /** 32 | * Throws {@link IllegalStateException}. 33 | * 34 | * @throws IllegalStateException always thrown. 35 | */ 36 | @Override 37 | public String toString() { 38 | throw new IllegalStateException(new NullPointerException(message)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/StringUtilsValueOfTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3; 18 | 19 | import org.junit.jupiter.api.Assertions; 20 | import org.junit.jupiter.api.Test; 21 | 22 | /** 23 | * Tests {@link StringUtils}'s valueOf() methods. 24 | */ 25 | public class StringUtilsValueOfTest extends AbstractLangTest { 26 | 27 | @Test 28 | public void testValueOfChar() { 29 | Assertions.assertEquals("ABC", StringUtils.valueOf(new char[] {'A', 'B', 'C' })); 30 | } 31 | 32 | @Test 33 | public void testValueOfCharEmpty() { 34 | Assertions.assertEquals(StringUtils.EMPTY, StringUtils.valueOf(ArrayUtils.EMPTY_CHAR_ARRAY)); 35 | } 36 | 37 | @Test 38 | public void testValueOfCharNull() { 39 | Assertions.assertNull(StringUtils.valueOf(null)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/builder/ConversionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.builder; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | import static org.junit.jupiter.api.Assertions.assertThrows; 21 | 22 | import org.apache.commons.lang3.Conversion; 23 | import org.junit.jupiter.api.Test; 24 | 25 | class ConversionTest { 26 | 27 | @Test 28 | void testHexToByte() { 29 | assertEquals((byte) 0, Conversion.hexToByte("00", 0, (byte) 0, 0, 0)); 30 | assertEquals((byte) 0, Conversion.hexToByte("00", 0, (byte) 0, 0, 2)); 31 | } 32 | 33 | @Test 34 | void testHexToByte_IllegalArgument() { 35 | assertThrows(IllegalArgumentException.class, () -> Conversion.hexToByte("A0", 0, (byte) 0, 4, 2)); 36 | } 37 | 38 | @Test 39 | void testHexToByte_nullString() { 40 | assertThrows(NullPointerException.class, () -> Conversion.hexToByte(null, 0, (byte) 0, 0, 2)); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/builder/IDKeyTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.builder; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; 21 | import static org.junit.jupiter.api.Assertions.assertNotEquals; 22 | 23 | import org.junit.jupiter.api.Test; 24 | 25 | /** 26 | * Tests {@link IDKey}. 27 | */ 28 | public class IDKeyTest { 29 | 30 | @Test 31 | public void testEquals() { 32 | assertEquals(new IDKey("1"), new IDKey("1")); 33 | assertNotEquals(new IDKey("1"), new IDKey("2")); 34 | assertNotEquals(new IDKey("1"), "2"); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderSummaryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.builder; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | 21 | import org.apache.commons.lang3.AbstractLangTest; 22 | import org.junit.jupiter.api.Test; 23 | 24 | public class ReflectionToStringBuilderSummaryTest extends AbstractLangTest { 25 | 26 | @SuppressWarnings("unused") 27 | private final String stringField = "string"; 28 | 29 | @ToStringSummary 30 | private final String summaryString = "summary"; 31 | 32 | @Test 33 | public void testSummary() { 34 | assertEquals("[stringField=string,summaryString=]", 35 | new ReflectionToStringBuilder(this, ToStringStyle.NO_CLASS_NAME_STYLE).build()); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.builder; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | 21 | import org.apache.commons.lang3.AbstractLangTest; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests {@link ReflectionToStringBuilder}. 26 | */ 27 | public class ReflectionToStringBuilderTest extends AbstractLangTest { 28 | 29 | @Test 30 | public void testConstructorWithNullObject() { 31 | assertEquals("", new ReflectionToStringBuilder(null, ToStringStyle.DEFAULT_STYLE, new StringBuffer()).toString()); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/concurrent/AtomicInitializerSupplierTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.concurrent; 18 | 19 | import org.apache.commons.lang3.function.FailableConsumer; 20 | import org.apache.commons.lang3.function.FailableSupplier; 21 | 22 | /** 23 | * Test class for {@code AtomicInitializer}. 24 | */ 25 | public class AtomicInitializerSupplierTest extends AbstractConcurrentInitializerCloseAndExceptionsTest { 26 | /** 27 | * Returns the initializer to be tested. 28 | * 29 | * @return the {@code AtomicInitializer} 30 | */ 31 | @Override 32 | protected ConcurrentInitializer createInitializer() { 33 | return AtomicInitializer.builder().setInitializer(Object::new).get(); 34 | } 35 | 36 | @Override 37 | protected ConcurrentInitializer createInitializerThatThrowsException( 38 | final FailableSupplier supplier, 39 | final FailableConsumer closer) { 40 | return AtomicInitializer.builder().setInitializer(supplier).setCloser(closer).get(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/concurrent/FutureTasksTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.concurrent; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | import static org.junit.jupiter.api.Assertions.assertTrue; 21 | 22 | import java.util.concurrent.ExecutionException; 23 | import java.util.concurrent.FutureTask; 24 | 25 | import org.apache.commons.lang3.AbstractLangTest; 26 | import org.junit.jupiter.api.Test; 27 | 28 | /** 29 | * Tests {@link FutureTask}. 30 | */ 31 | public class FutureTasksTest extends AbstractLangTest { 32 | 33 | @Test 34 | public void testRun() throws InterruptedException, ExecutionException { 35 | final String data = "Hello"; 36 | final FutureTask f = FutureTasks.run(() -> data); 37 | assertTrue(f.isDone()); 38 | assertEquals(data, f.get()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerAnonClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.concurrent; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertFalse; 20 | import static org.junit.jupiter.api.Assertions.assertTrue; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests {@code LazyInitializer}. 26 | */ 27 | public class LazyInitializerAnonClassTest extends AbstractConcurrentInitializerTest { 28 | 29 | /** 30 | * Creates the initializer to be tested. This implementation returns the {@code LazyInitializer} created in the {@code setUp()} method. 31 | * 32 | * @return the initializer to be tested 33 | */ 34 | @Override 35 | protected LazyInitializer createInitializer() { 36 | return new LazyInitializer() { 37 | @Override 38 | protected Object initialize() { 39 | return new Object(); 40 | } 41 | }; 42 | } 43 | 44 | @Test 45 | public void testIsInitialized() throws ConcurrentException { 46 | final LazyInitializer initializer = createInitializer(); 47 | assertFalse(initializer.isInitialized()); 48 | initializer.get(); 49 | assertTrue(initializer.isInitialized()); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerSupplierTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.concurrent; 18 | 19 | import org.apache.commons.lang3.function.FailableConsumer; 20 | import org.apache.commons.lang3.function.FailableSupplier; 21 | 22 | /** 23 | * Tests {@code LazyInitializer}. 24 | */ 25 | public class LazyInitializerSupplierTest extends AbstractConcurrentInitializerCloseAndExceptionsTest { 26 | 27 | /** 28 | * Creates the initializer to be tested. 29 | * 30 | * @return the initializer to be tested 31 | */ 32 | @Override 33 | protected ConcurrentInitializer createInitializer() { 34 | return LazyInitializer.builder().setInitializer(Object::new).get(); 35 | } 36 | 37 | @Override 38 | protected ConcurrentInitializer createInitializerThatThrowsException( 39 | final FailableSupplier supplier, 40 | final FailableConsumer closer) { 41 | return LazyInitializer.builder().setInitializer(supplier).setCloser(closer).get(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/concurrent/UncheckedExecutionExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.concurrent; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertSame; 20 | 21 | import org.apache.commons.lang3.AbstractLangTest; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests {@link UncheckedExecutionException}. 26 | */ 27 | public class UncheckedExecutionExceptionTest extends AbstractLangTest { 28 | 29 | @Test 30 | public void testConstructWithCause() { 31 | final Exception e = new Exception(); 32 | assertSame(e, new UncheckedExecutionException(e).getCause()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/concurrent/UncheckedTimeoutExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.concurrent; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertSame; 20 | 21 | import org.apache.commons.lang3.AbstractLangTest; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests {@link UncheckedTimeoutException}. 26 | */ 27 | public class UncheckedTimeoutExceptionTest extends AbstractLangTest { 28 | 29 | @Test 30 | public void testConstructWithCause() { 31 | final Exception e = new Exception(); 32 | assertSame(e, new UncheckedTimeoutException(e).getCause()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.exception; 18 | 19 | import org.apache.commons.lang3.AbstractLangTest; 20 | 21 | /** 22 | * Base class for testing {@link Exception} descendants 23 | */ 24 | public abstract class AbstractExceptionTest extends AbstractLangTest { 25 | 26 | protected static final String CAUSE_MESSAGE = "Cause message"; 27 | protected static final String EXCEPTION_MESSAGE = "Exception message"; 28 | 29 | protected static final String WRONG_EXCEPTION_MESSAGE = "Wrong exception message"; 30 | protected static final String WRONG_CAUSE_MESSAGE = "Wrong cause message"; 31 | 32 | protected Exception generateCause() { 33 | return new Exception(CAUSE_MESSAGE); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/exception/CustomCheckedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.exception; 19 | 20 | public class CustomCheckedException extends Exception { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | public CustomCheckedException() { 25 | } 26 | 27 | public CustomCheckedException(final String message) { 28 | super(message); 29 | } 30 | 31 | public CustomCheckedException(final String message, final Throwable cause) { 32 | super(message, cause); 33 | } 34 | 35 | public CustomCheckedException(final Throwable cause) { 36 | super(cause); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/exception/CustomUncheckedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.exception; 19 | 20 | public class CustomUncheckedException extends RuntimeException { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | public CustomUncheckedException() { 25 | } 26 | 27 | public CustomUncheckedException(final String message) { 28 | super(message); 29 | } 30 | 31 | public CustomUncheckedException(final String message, final Throwable cause) { 32 | super(message, cause); 33 | } 34 | 35 | public CustomUncheckedException(final Throwable cause) { 36 | super(cause); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/exception/UncheckedExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.exception; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertSame; 20 | 21 | import org.apache.commons.lang3.AbstractLangTest; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests {@link UncheckedException}. 26 | */ 27 | public class UncheckedExceptionTest extends AbstractLangTest { 28 | 29 | @Test 30 | public void testConstructWithCause() { 31 | final Exception e = new Exception(); 32 | assertSame(e, new UncheckedException(e).getCause()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/exception/UncheckedIllegalAccessExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.exception; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertSame; 20 | 21 | import org.apache.commons.lang3.AbstractLangTest; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests {@link UncheckedIllegalAccessException}. 26 | */ 27 | public class UncheckedIllegalAccessExceptionTest extends AbstractLangTest { 28 | 29 | @Test 30 | public void testConstructWithCause() { 31 | final Exception e = new Exception(); 32 | assertSame(e, new UncheckedIllegalAccessException(e).getCause()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/exception/UncheckedInterruptedExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.exception; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertSame; 20 | 21 | import org.apache.commons.lang3.AbstractLangTest; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests {@link UncheckedInterruptedException}. 26 | */ 27 | public class UncheckedInterruptedExceptionTest extends AbstractLangTest { 28 | 29 | @Test 30 | public void testConstructWithCause() { 31 | final Exception e = new Exception(); 32 | assertSame(e, new UncheckedInterruptedException(e).getCause()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/exception/UncheckedReflectiveOperationExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.exception; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertSame; 20 | 21 | import org.apache.commons.lang3.AbstractLangTest; 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests {@link UncheckedReflectiveOperationException}. 26 | */ 27 | public class UncheckedReflectiveOperationExceptionTest extends AbstractLangTest { 28 | 29 | @Test 30 | public void testConstructWithCause() { 31 | final Exception e = new Exception(); 32 | assertSame(e, new UncheckedReflectiveOperationException(e).getCause()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/function/AnnotationTestFixture.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | @Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD }) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @interface AnnotationTestFixture { 28 | // empty 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/function/FailableSupplierTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertNull; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Tests {@link FailableSupplier}. 26 | */ 27 | public class FailableSupplierTest { 28 | 29 | @Test 30 | public void testNULL() throws Throwable { 31 | assertNull(FailableSupplier.NUL.get()); 32 | } 33 | 34 | @Test 35 | public void testNullSupplierDefaultException() throws Exception { 36 | assertNull(FailableSupplier.nul().get()); 37 | } 38 | 39 | @Test 40 | public void testNullSupplierException() throws Exception { 41 | assertNull(FailableSupplier.nul().get()); 42 | } 43 | 44 | @Test 45 | public void testNullSupplierRuntimeException() { 46 | assertNull(FailableSupplier.nul().get()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/function/FunctionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; 21 | import static org.junit.jupiter.api.Assertions.assertFalse; 22 | import static org.junit.jupiter.api.Assertions.assertNull; 23 | import static org.junit.jupiter.api.Assertions.assertTrue; 24 | 25 | import java.util.concurrent.atomic.AtomicBoolean; 26 | import java.util.function.Function; 27 | 28 | import org.junit.jupiter.api.Test; 29 | 30 | /** 31 | * Tests {@link Functions}. 32 | */ 33 | public class FunctionsTest { 34 | 35 | /** 36 | * Tests {@link Functions#apply(Function, Object)}. 37 | */ 38 | @Test 39 | public void testApply() { 40 | final AtomicBoolean bool = new AtomicBoolean(); 41 | assertFalse(Functions.apply(bool::getAndSet, true)); 42 | assertTrue(bool.get()); 43 | assertNull(Functions.apply(null, "foo")); 44 | assertNull(Functions.apply(null, null)); 45 | } 46 | 47 | /** 48 | * Tests {@link Functions#function(Function)}. 49 | */ 50 | @Test 51 | public void testFunction() { 52 | assertEquals("foo", Functions.function(String::valueOf).andThen(String::toString).apply("foo")); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/function/IntToCharFunctionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; 21 | 22 | import org.apache.commons.lang3.AbstractLangTest; 23 | import org.junit.jupiter.api.Test; 24 | 25 | /** 26 | * Tests {@link IntToCharFunction}. 27 | */ 28 | public class IntToCharFunctionTest extends AbstractLangTest { 29 | 30 | @Test 31 | public void test() { 32 | final IntToCharFunction func = i -> (char) i; 33 | assertEquals('A', func.applyAsChar(65)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/function/MethodInvokersFailableSupplierTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; 21 | import static org.junit.jupiter.api.Assertions.assertFalse; 22 | 23 | import java.lang.reflect.Method; 24 | 25 | import org.junit.jupiter.api.Test; 26 | 27 | /** 28 | * Tests {@link MethodInvokers#asFailableSupplier(Method)}. 29 | */ 30 | public class MethodInvokersFailableSupplierTest extends MethodFixtures { 31 | 32 | @Test 33 | public void testSupplierStatic() throws Throwable { 34 | assertEquals(staticGetString(), MethodInvokers.asFailableSupplier(getMethodForStaticGetString()).get()); 35 | assertEquals(staticGetString(), MethodInvokers.asFailableSupplier(getMethodForStaticGetString()).get()); 36 | } 37 | 38 | @Test 39 | public void testSupplierToString() throws SecurityException, ReflectiveOperationException { 40 | // Should not blow up and must return _something_ 41 | assertFalse(MethodInvokers.asFailableSupplier(getMethodForStaticGetString()).toString().isEmpty()); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/function/MethodInvokersSupplierTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; 21 | import static org.junit.jupiter.api.Assertions.assertFalse; 22 | 23 | import java.lang.reflect.Method; 24 | import java.util.function.Supplier; 25 | 26 | import org.junit.jupiter.api.Test; 27 | 28 | /** 29 | * Tests {@link MethodInvokers#asSupplier(Method)}. 30 | */ 31 | public class MethodInvokersSupplierTest extends MethodFixtures { 32 | 33 | @Test 34 | public void testSupplierStaticGetMethod() throws NoSuchMethodException, SecurityException { 35 | final Supplier supplier = MethodInvokers.asSupplier(getMethodForStaticGetString()); 36 | assertEquals(staticGetString(), supplier.get()); 37 | assertEquals(staticGetString(), supplier.get()); 38 | } 39 | 40 | @Test 41 | public void testSupplierStaticGetMethodToString() throws SecurityException, ReflectiveOperationException { 42 | // Should not blow up and must return _something_ 43 | final Supplier supplier = MethodInvokers.asSupplier(getMethodForStaticGetString()); 44 | assertFalse(supplier.toString().isEmpty()); 45 | assertFalse(supplier.toString().isEmpty()); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/function/PredicatesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertFalse; 21 | import static org.junit.jupiter.api.Assertions.assertTrue; 22 | 23 | import java.util.function.Predicate; 24 | 25 | import org.junit.jupiter.api.Test; 26 | 27 | /** 28 | * Tests {@link Predicates}. 29 | */ 30 | public class PredicatesTest { 31 | 32 | @Test 33 | public void testFalsePredicate() { 34 | assertFalse(Predicates.falsePredicate().test(null)); 35 | assertFalse(Predicates.falsePredicate().test(new Object())); 36 | final Predicate stringPredicate = Predicates.falsePredicate(); 37 | assertFalse(stringPredicate.test(null)); 38 | assertFalse(stringPredicate.test("")); 39 | } 40 | 41 | @Test 42 | public void testTruePredicate() { 43 | assertTrue(Predicates.truePredicate().test(null)); 44 | assertTrue(Predicates.truePredicate().test(new Object())); 45 | final Predicate stringPredicate = Predicates.truePredicate(); 46 | assertTrue(stringPredicate.test(null)); 47 | assertTrue(stringPredicate.test("")); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/function/SuppliersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; 21 | import static org.junit.jupiter.api.Assertions.assertNull; 22 | 23 | import java.util.function.Supplier; 24 | 25 | import org.apache.commons.lang3.AbstractLangTest; 26 | import org.junit.jupiter.api.Test; 27 | 28 | /** 29 | * Tests {@link Suppliers}. 30 | */ 31 | public class SuppliersTest extends AbstractLangTest { 32 | 33 | /** 34 | * Tests {@link Suppliers#get(Supplier)}. 35 | */ 36 | @Test 37 | public void testGet() { 38 | assertNull(Suppliers.get(null)); 39 | assertNull(Suppliers.get(() -> null)); 40 | assertNull(Suppliers.get(Suppliers.nul())); 41 | assertEquals("foo", Suppliers.get(() -> "foo")); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/function/ToBooleanBiFunctionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.function; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertTrue; 21 | 22 | import org.apache.commons.lang3.AbstractLangTest; 23 | import org.junit.jupiter.api.Test; 24 | 25 | /** 26 | * Tests {@link ToBooleanBiFunction}. 27 | */ 28 | public class ToBooleanBiFunctionTest extends AbstractLangTest { 29 | 30 | @Test 31 | public void test() { 32 | final ToBooleanBiFunction func = (t, u) -> Integer.valueOf(t).equals(u); 33 | assertTrue(func.applyAsBoolean("1", 1)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/mutable/PrintAtomicVsMutable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.mutable; 19 | 20 | import java.util.concurrent.atomic.AtomicInteger; 21 | 22 | import org.apache.commons.lang3.time.DurationUtils; 23 | 24 | /** 25 | * Prints out the difference time working with {@link MutableInt} and {@link AtomicInteger}. 26 | */ 27 | public class PrintAtomicVsMutable { 28 | 29 | public static void main(final String[] args) { 30 | final MutableInt mInt = new MutableInt(); 31 | final int max = 100_000_000; 32 | System.out.println("MutableInt " + DurationUtils.of(() -> { 33 | for (int i = 0; i < max; i++) { 34 | mInt.incrementAndGet(); 35 | } 36 | })); 37 | final AtomicInteger aInt = new AtomicInteger(); 38 | System.out.println("AtomicInteger " + DurationUtils.of(() -> { 39 | for (int i = 0; i < max; i++) { 40 | aInt.incrementAndGet(); 41 | } 42 | })); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/Lang1703Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.reflect; 19 | 20 | import org.junit.jupiter.api.Test; 21 | 22 | /** 23 | * A top-level class is parameterised using itself. 24 | * 25 | * @param itself 26 | */ 27 | public class Lang1703Test> { 28 | 29 | @Test 30 | public void testStackOverflowError() { 31 | // causes a java.lang.StackOverflowError 32 | TypeUtils.toString(Lang1703Test.class); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/Ambig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | */ 21 | public class Ambig implements Foo, Bar { 22 | 23 | @Override 24 | public void doIt() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/Annotated.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.reflect.testbed; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | @Retention(RetentionPolicy.RUNTIME) 26 | @Target({ElementType.FIELD, ElementType.METHOD}) 27 | public @interface Annotated { 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/AnotherChild.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | */ 21 | public class AnotherChild extends AnotherParent { 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/AnotherParent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | * An empty public class. 21 | */ 22 | public class AnotherParent { 23 | // keep empty. 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/Bar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | */ 21 | public interface Bar { 22 | String VALUE = "bar"; 23 | 24 | void doIt(); 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | */ 21 | public interface Foo { 22 | String VALUE = "foo"; 23 | 24 | @Annotated 25 | void doIt(); 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/GenericConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | public interface GenericConsumer { 20 | void consume(T t); 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/GenericParent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | * Class declaring a parameter variable. 21 | */ 22 | public class GenericParent implements GenericConsumer { 23 | 24 | @Override 25 | public void consume(final T t) { 26 | } 27 | 28 | public void parentNotAnnotatedMethod(final T t) { 29 | } 30 | 31 | @Annotated 32 | protected void parentProtectedAnnotatedMethod(final T t) { 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/GenericTypeHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * Holds generic testbed types. 23 | */ 24 | @SuppressWarnings("rawtypes") 25 | public class GenericTypeHolder { 26 | public GenericParent stringParent; 27 | public GenericParent integerParent; 28 | public List foos; 29 | public GenericParent[] barParents; 30 | public List rawList; 31 | public List objectList; 32 | public List unboundList; 33 | public List superObjectList; 34 | public List stringList; 35 | public List subStringList; 36 | public List superStringList; 37 | public List[] rawListArray; 38 | public List[] objectListArray; 39 | public List[] unboundListArray; 40 | public List[] superObjectListArray; 41 | public List[] stringListArray; 42 | public List[] subStringListArray; 43 | public List[] superStringListArray; 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/Grandchild.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | */ 21 | public class Grandchild extends AnotherChild { 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/Parent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | */ 21 | class Parent implements Foo { 22 | 23 | public String s = "s"; 24 | protected boolean b; 25 | int i; 26 | 27 | @SuppressWarnings("unused") 28 | private final double d = 0.0; 29 | 30 | @Override 31 | public void doIt() { 32 | } 33 | 34 | public void parentNotAnnotatedMethod() { 35 | } 36 | 37 | @Annotated 38 | protected void parentProtectedAnnotatedMethod() { 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/PrivatelyShadowedChild.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | */ 21 | @SuppressWarnings({ "unused" }) // deliberate re-use of variable names 22 | public class PrivatelyShadowedChild extends Parent { 23 | private final String s = "ss"; 24 | private final boolean b = true; 25 | private final int i = 1; 26 | private final double d = 1.0; 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/PublicChild.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | */ 21 | public class PublicChild extends Parent { 22 | static final String VALUE = "child"; 23 | 24 | @Override 25 | public void parentNotAnnotatedMethod() { 26 | } 27 | 28 | @Override 29 | public void parentProtectedAnnotatedMethod() { 30 | } 31 | 32 | @Annotated 33 | private void privateAnnotatedMethod() { 34 | } 35 | 36 | @Annotated 37 | public void publicAnnotatedMethod() { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/PubliclyShadowedChild.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | */ 21 | public class PubliclyShadowedChild extends Parent { 22 | public String s = "ss"; 23 | public boolean b = true; 24 | public int i = 1; 25 | public double d = 1.0; 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/StaticContainerChild.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | */ 21 | public class StaticContainerChild extends StaticContainer { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/reflect/testbed/StringParameterizedChild.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.reflect.testbed; 18 | 19 | /** 20 | * {@link GenericParent} subclass that explicitly specifies <T> as {@link String}. 21 | */ 22 | public class StringParameterizedChild extends GenericParent { 23 | @Override 24 | public void consume(final String t) { 25 | super.consume(t); 26 | } 27 | 28 | @Override 29 | public void parentNotAnnotatedMethod(final String t) { 30 | } 31 | 32 | @Override 33 | public void parentProtectedAnnotatedMethod(final String t) { 34 | } 35 | 36 | @Annotated 37 | private void privateAnnotatedMethod(final String t) { 38 | } 39 | 40 | @Annotated 41 | public void publicAnnotatedMethod(final String t) { 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/stream/IntStreamsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.stream; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertArrayEquals; 20 | import static org.junit.jupiter.api.Assertions.assertEquals; 21 | 22 | import org.apache.commons.lang3.AbstractLangTest; 23 | import org.junit.jupiter.api.Test; 24 | 25 | /** 26 | * Tests {@link IntStreams}. 27 | */ 28 | public class IntStreamsTest extends AbstractLangTest { 29 | 30 | @Test 31 | public void testOfArray() { 32 | assertEquals(0, IntStreams.of((int[]) null).count()); 33 | assertEquals(1, IntStreams.of(1).count()); 34 | assertEquals(2, IntStreams.of(1, 2).count()); 35 | } 36 | 37 | @Test 38 | public void testRange() { 39 | assertArrayEquals(new int[] {0, 1}, IntStreams.range(2).toArray()); 40 | } 41 | 42 | @Test 43 | public void testRangeClosed() { 44 | assertArrayEquals(new int[] {0, 1, 2}, IntStreams.rangeClosed(2).toArray()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/test/NotVisibleExceptionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.test; 18 | 19 | /** 20 | * Allows for testing an exception that is not visible to {@link org.apache.commons.lang3.exception.ExceptionUtils} 21 | */ 22 | public class NotVisibleExceptionFactory { 23 | 24 | private static final class NotVisibleException extends Exception { 25 | 26 | private static final long serialVersionUID = 1L; // avoid warning 27 | 28 | private final Throwable cause; 29 | 30 | private NotVisibleException(final Throwable cause) { 31 | this.cause = cause; 32 | } 33 | 34 | @Override 35 | public synchronized Throwable getCause() { 36 | return cause; 37 | } 38 | } 39 | 40 | /** 41 | * Create a new Exception whose getCause method returns the provided cause. 42 | * 43 | * @param cause the cause of the exception 44 | * @return a new {@link Exception} 45 | */ 46 | public static Exception createException(final Throwable cause) { 47 | return new NotVisibleException(cause); 48 | } 49 | 50 | private NotVisibleExceptionFactory() { 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/time/FastDateFormat_PrinterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.time; 18 | 19 | import java.util.Locale; 20 | import java.util.TimeZone; 21 | 22 | /** 23 | * Tests for the print methods of FastDateFormat 24 | */ 25 | public class FastDateFormat_PrinterTest extends FastDatePrinterTest { 26 | 27 | @Override 28 | protected DatePrinter getInstance(final String format, final TimeZone timeZone, final Locale locale) { 29 | return FastDateFormat.getInstance(format, timeZone, locale); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.lang3.time; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | 21 | import java.text.SimpleDateFormat; 22 | import java.util.Calendar; 23 | import java.util.TimeZone; 24 | import java.util.stream.Stream; 25 | 26 | import org.apache.commons.lang3.AbstractLangTest; 27 | import org.junit.jupiter.params.ParameterizedTest; 28 | import org.junit.jupiter.params.provider.MethodSource; 29 | 30 | public class FastDatePrinterTimeZonesTest extends AbstractLangTest { 31 | 32 | private static final String PATTERN = "h:mma z"; 33 | 34 | public static Stream data() { 35 | return Stream.of(TimeZone.getAvailableIDs()).map(TimeZone::getTimeZone); 36 | } 37 | 38 | @ParameterizedTest 39 | @MethodSource("data") 40 | public void testCalendarTimezoneRespected(final TimeZone timeZone) { 41 | final Calendar cal = Calendar.getInstance(timeZone); 42 | 43 | final SimpleDateFormat sdf = new SimpleDateFormat(PATTERN); 44 | sdf.setTimeZone(timeZone); 45 | final String expectedValue = sdf.format(cal.getTime()); 46 | final String actualValue = FastDateFormat.getInstance(PATTERN, timeZone).format(cal); 47 | assertEquals(expectedValue, actualValue); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/org/apache/commons/lang3/time/TimeZonesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.lang3.time; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; 21 | 22 | import java.util.TimeZone; 23 | 24 | import org.junit.jupiter.api.Test; 25 | 26 | /** 27 | * Tests {@link TimeZones}. 28 | */ 29 | public class TimeZonesTest { 30 | 31 | static final String TIME_ZONE_GET_AVAILABLE_IDS = "java.util.TimeZone#getAvailableIDs()"; 32 | 33 | @Test 34 | public void testToTimeZone() { 35 | assertEquals(TimeZone.getDefault(), TimeZones.toTimeZone(null)); 36 | assertEquals(TimeZone.getDefault(), TimeZones.toTimeZone(TimeZone.getDefault())); 37 | assertEquals(TimeZones.GMT, TimeZones.toTimeZone(TimeZones.GMT)); 38 | } 39 | } 40 | --------------------------------------------------------------------------------