[java-support] branch master updated: Add a utility class for constructing language-specific strings.
Scott Cantor
cantor.2 at osu.edu
Thu Aug 18 21:15:03 EDT 2016
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-support.
View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=930a725e1a427544ffae91c4edffafa153492faa
The following commit(s) were added to refs/heads/master by this push:
new 930a725 Add a utility class for constructing language-specific strings.
930a725 is described below
commit 930a725e1a427544ffae91c4edffafa153492faa
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Aug 18 21:14:46 2016 -0400
Add a utility class for constructing language-specific strings.
---
.../java/support/primitive/LangBearingString.java | 79 ++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/src/main/java/net/shibboleth/utilities/java/support/primitive/LangBearingString.java b/src/main/java/net/shibboleth/utilities/java/support/primitive/LangBearingString.java
new file mode 100644
index 0000000..08fb532
--- /dev/null
+++ b/src/main/java/net/shibboleth/utilities/java/support/primitive/LangBearingString.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.utilities.java.support.primitive;
+
+import javax.annotation.Nullable;
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.collection.Pair;
+
+/**
+ * An object that represents a string associated with a language tag/locale.
+ */
+public class LangBearingString extends Pair<String,String> {
+
+ /**
+ * Constructor.
+ *
+ * @param value the value
+ */
+ public LangBearingString(@Nullable final String value) {
+ super(value, null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param value the value
+ * @param lang the language
+ */
+ public LangBearingString(@Nullable final String value, @Nullable @NotEmpty final String lang) {
+ super(value, StringSupport.trimOrNull(lang));
+ }
+
+ /**
+ * Get the string value.
+ *
+ * @return value
+ */
+ @Nullable public String getValue() {
+ return getFirst();
+ }
+
+ /**
+ * Get the language.
+ *
+ * @return language
+ */
+ @Nullable @NotEmpty public String getLang() {
+ return getSecond();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setSecond(@Nullable final String newSecond) {
+ super.setSecond(StringSupport.trimOrNull(newSecond));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return getValue();
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list