diff --git a/.gitignore b/.gitignore
index 0861ab5..20149da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,5 @@ target
*/.classpath
*/.project
*/.settings
+*/build/
+.gradle
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..cc5c502
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# デフォルトの無視対象ファイル
+/shelf/
+/workspace.xml
+# エディターベースの HTTP クライアントリクエスト
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..0e763e7
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..e20b48a
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..616e105
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..73a6a03
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..c224ad5
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..d5e2185
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/actions/build.gradle.kts b/actions/build.gradle.kts
new file mode 100644
index 0000000..eecf180
--- /dev/null
+++ b/actions/build.gradle.kts
@@ -0,0 +1,24 @@
+/*
+ * This file was generated by the Gradle 'init' task.
+ */
+
+plugins {
+ kotlin("jvm")
+}
+
+dependencies {
+ api(project(":core"))
+ testImplementation(libs.junit.junit)
+ implementation(kotlin("stdlib-jdk8"))
+}
+
+description = "Activity Streams 2.0 - Actions"
+repositories {
+ mavenCentral()
+}
+kotlin {
+ jvmToolchain(11)
+}
+tasks.test {
+ useJUnit()
+}
\ No newline at end of file
diff --git a/actions/pom.xml b/actions/pom.xml
deleted file mode 100644
index 0d074df..0000000
--- a/actions/pom.xml
+++ /dev/null
@@ -1,142 +0,0 @@
-
- 4.0.0
-
- com.ibm.common
- activitystreams
- 0.0.1-SNAPSHOT
-
- activitystreams-actions
- Activity Streams 2.0 - Actions
-
-
-
- Apache License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
-
-
-
-
- UTF-8
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.9.1
-
- UTF-8
- UTF-8
- UTF-8
- -XDignore.symbol.file
- public
-
- http://www.joda.org/joda-time/apidocs
- http://docs.guava-libraries.googlecode.com/git-history/v16.0.1/javadoc/
-
-
-
-
-
- maven-compiler-plugin
- 2.3.2
-
- 1.7
- 1.7
-
-
-
-
- maven-jar-plugin
- 2.3.1
-
-
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
-
-
-
-
- org.apache.felix
- maven-bundle-plugin
- 2.3.7
- true
-
-
- bundle-manifest
- process-classes
-
- manifest
-
-
-
-
-
- com.ibm.common.activitystreams.actions.*
-
- com.ibm.common.activitystreams.*,
- com.google.gson.*,
- com.google.common.*,
- org.joda.time.*
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
- 2.2.2
-
-
- assembly.xml
-
-
-
-
-
-
-
-
-
- org.eclipse.m2e
- lifecycle-mapping
- 1.0.0
-
-
-
-
-
- org.apache.felix
- maven-bundle-plugin
- [2.3.7,)
-
- manifest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- com.ibm.common
- activitystreams-core
- 0.0.1-SNAPSHOT
-
-
- junit
- junit
-
-
-
\ No newline at end of file
diff --git a/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionHandler.java b/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionHandler.java
deleted file mode 100755
index 843581d..0000000
--- a/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionHandler.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/**
- * Copyright 2013 OpenSocial Foundation
- * Copyright 2013 International Business Machines Corporation
- *
- * Licensed 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.
- *
- * Utility library for working with Activity Streams Actions
- * Requires underscorejs.
- *
- * @author James M Snell (jasnell@us.ibm.com)
- */
-package com.ibm.common.activitystreams.actions;
-
-import java.io.Serializable;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.ibm.common.activitystreams.ASObject;
-import com.ibm.common.activitystreams.LinkValue;
-
-/**
- */
-public abstract class ActionHandler
- extends ASObject
- implements Serializable {
-
- /**
- */
- @SuppressWarnings("unchecked")
- public static abstract class Builder>
- extends ASObject.AbstractBuilder {
-
- private final Authentication.Builder auth =
- Authentication.make();
-
- public Builder() {
- writeUsing(ActionMakers.io);
- }
-
- /**
- * Method confirm.
- * @return B
- */
- public B confirm() {
- return confirm(true);
- }
-
- /**
- * Method confirm.
- * @param on boolean
- * @return B
- */
- public B confirm(boolean on) {
- set("confirm", on);
- return (B)this;
- }
-
- /**
- * Method context.
- * @param obj ASObject
- * @return B
- */
- public B context(ASObject obj) {
- set("context", obj);
- return (B)this;
- }
-
- /**
- * Method context.
- * @param obj Supplier extends ASObject>
- * @return B
- */
- public B context(Supplier extends ASObject> obj) {
- return context(obj.get());
- }
-
- /**
- * Method requires.
- * @param iri String
- * @return B
- */
- public B requires(String iri, String... iris) {
- requires(LinkValue.SimpleLinkValue.make(iri));
- if (iris != null)
- for (String i : iris)
- requires(i);
- return (B)this;
- }
-
- /**
- * Method requires.
- * @param lv LinkValue
- * @return B
- */
- public B requires(LinkValue lv, LinkValue... lvs) {
- link("requires", lv);
- if (lvs != null)
- for (LinkValue i : lvs)
- requires(i);
- return (B)this;
- }
-
- /**
- * Method requires.
- * @param lv Supplier extends LinkValue>
- * @return B
- */
- public B requires(Supplier extends LinkValue> lv) {
- return requires(lv.get());
- }
-
- /**
- * Method prefers.
- * @param iri String
- * @return B
- */
- public B prefers(String iri, String... iris) {
- prefers(LinkValue.SimpleLinkValue.make(iri));
- if (iris != null)
- for (String i : iris)
- prefers(i);
- return (B) this;
- }
-
- /**
- * Method prefers.
- * @param lv LinkValue
- * @return B
- */
- public B prefers(LinkValue lv, LinkValue... lvs) {
- link("prefers", lv);
- if (lvs != null)
- for (LinkValue l : lvs)
- prefers(l);
- return (B)this;
- }
-
- /**
- * Method prefers.
- * @param lv Supplier extends LinkValue>
- * @return B
- */
- public B prefers(Supplier extends LinkValue> lv) {
- return prefers(lv.get());
- }
-
- /**
- * Method expects.
- * @param iri String
- * @return B
- */
- public B expects(String iri, String... iris) {
- expects(LinkValue.SimpleLinkValue.make(iri));
- if (iris != null)
- for (String i : iris)
- expects(i);
- return (B)this;
- }
-
- /**
- * Method expects.
- * @param tv LinkValue
- * @return B
- */
- public B expects(LinkValue tv, LinkValue... lvs) {
- link("expects", tv);
- if (lvs != null)
- for (LinkValue lv : lvs)
- expects(lv);
- return (B)this;
- }
-
- /**
- * Method expects.
- * @param tv Supplier extends LinkValue>
- * @return B
- */
- public B expects(Supplier extends LinkValue> tv) {
- return expects(tv.get());
- }
-
- /**
- * Method returns.
- * @param iri String
- * @return B
- */
- public B returns(String iri, String... iris) {
- returns(LinkValue.SimpleLinkValue.make(iri));
- if (iris != null)
- for (String i : iris)
- returns(i);
- return (B)this;
- }
-
- /**
- * Method returns.
- * @param tv LinkValue
- * @return B
- */
- public B returns(LinkValue tv, LinkValue... lvs) {
- link("returns", tv);
- if (lvs != null)
- for (LinkValue lv : lvs)
- returns(lv);
- return (B)this;
- }
-
- /**
- * Method returns.
- * @param tv Supplier extends LinkValue>
- * @return B
- */
- public B returns(Supplier extends LinkValue> tv) {
- return returns(tv.get());
- }
-
- /**
- * Method auth.
- * @param key String
- * @param obj ASObject
- * @return B
- */
- public B auth(String key, ASObject obj) {
- auth.set(key, obj);
- return (B)this;
- }
-
- /**
- * Method auth.
- * @param key String
- * @param obj Supplier extends ASObject>
- * @return B
- */
- public B auth(String key, Supplier extends ASObject> obj) {
- return auth(key, obj.get());
- }
-
- /**
- * Method get.
- * @return A
- * @see com.google.common.base.Supplier#get()
- */
- public A get() {
- if (auth.notEmpty())
- set("auth", auth.get());
- return actualGet();
- }
-
- /**
- * Method actualGet.
- * @return A
- */
- protected abstract A actualGet();
- }
-
- /**
- * Constructor for ActionHandler.
- * @param builder Builder,?>
- */
- protected ActionHandler(Builder,?> builder) {
- super(builder);
- }
-
- /**
- * Method confirm.
- * @return boolean
- */
- public boolean confirm() {
- return this.getBoolean("confirm");
- }
-
- /**
- * Method context.
- * @return A
- */
- public A context() {
- return this.get("context");
- }
-
- /**
- * Method expects.
- * @return Iterable
- */
- public Iterable expects() {
- return this.links("expects");
- }
-
- public Iterable expects(Predicate super LinkValue> filter) {
- return this.links("expects", filter);
- }
-
- /**
- * Method requires.
- * @return Iterable
- */
- public Iterable requires() {
- return this.links("requires");
- }
-
- public Iterable requires(Predicate super LinkValue> filter) {
- return this.links("requires", filter);
- }
-
- /**
- * Method prefers.
- * @return Iterable
- */
- public Iterable prefers() {
- return this.links("prefers");
- }
-
- public Iterable prefers(Predicate super LinkValue> filter) {
- return this.links("prefers", filter);
- }
-
- /**
- * Method returns.
- * @return Iterable
- */
- public Iterable returns() {
- return this.links("returns");
- }
-
- public Iterable returns(Predicate super LinkValue> filter) {
- return this.links("returns", filter);
- }
-
- /**
- * Method auth.
- * @return Authentication
- */
- public Authentication auth() {
- return this.get("auth");
- }
-
- /**
- * Method hasAuth.
- * @param key String
- * @return boolean
- */
- public boolean hasAuth(String key) {
- Authentication auth = auth();
- return auth != null ?
- auth.has(key) : false;
- }
-
- /**
- * Method auth.
- * @param key String
- * @return A
- */
- @SuppressWarnings("unchecked")
- public A auth(String key) {
- Authentication auth = auth();
- return auth != null ?
- (A)auth.get(key) : null;
- }
-
-}
diff --git a/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionMakers.java b/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionMakers.java
deleted file mode 100755
index 71bd7fb..0000000
--- a/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionMakers.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/**
- * Copyright 2013 OpenSocial Foundation
- * Copyright 2013 International Business Machines Corporation
- *
- * Licensed 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.
- *
- * Utility library for working with Activity Streams Actions
- * Requires underscorejs.
- *
- * @author James M Snell (jasnell@us.ibm.com)
- */
-package com.ibm.common.activitystreams.actions;
-
-import static com.ibm.common.activitystreams.Makers.object;
-
-import com.ibm.common.activitystreams.ASObject;
-import com.ibm.common.activitystreams.IO;
-import com.ibm.common.activitystreams.actions.ParameterValue.SimpleParameterValue;
-
-/**
- */
-public final class ActionMakers {
-
- public static final IO io =
- IO.makeDefault(ActionsModule.instance);
- public static final IO ioPretty =
- IO.makeDefaultPrettyPrint(ActionsModule.instance);
-
- public static final String TARGET_NONE = "NONE";
- public static final String TARGET_DEFAULT = "DEFAULT";
- public static final String TARGET_NEW = "NEW";
- public static final String TARGET_CURRENT = "CURRENT";
- public static final String TARGET_TAB = "TAB";
- public static final String TARGET_DIALOG = "DIALOG";
- public static final String TARGET_MODALDIALOG = "MODALDIALOG";
- public static final String TARGET_FLOAT = "FLOAT";
- public static final String TARGET_SIDEBAR = "SIDEBAR";
-
- public static final String METHOD_GET = "GET";
- public static final String METHOD_POST = "POST";
- public static final String METHOD_PUT = "PUT";
- public static final String METHOD_DELETE = "DELETE";
- public static final String METHOD_PATCH = "PATCH";
-
- private ActionMakers() {}
-
- /**
- * Method application.
- * @return ASObject.Builder
- */
- public static ASObject.Builder application() {
- return object("application");
- }
-
- /**
- * Method service.
- * @return ASObject.Builder
- */
- public static ASObject.Builder service() {
- return object("service");
- }
-
- /**
- * Method styles.
- * @return StylesValue.Builder
- */
- public static StylesValue.Builder styles() {
- return StylesValue.make();
- }
-
- /**
- * Method styles.
- * @param media String
- * @return StylesValue.Builder
- */
- public static StylesValue.Builder styles(String media) {
- return styles().media(media);
- }
-
- /**
- * Method httpAction.
- * @return HttpActionHandler.Builder
- */
- public static HttpActionHandler.Builder httpAction() {
- return HttpActionHandler.makeHttpActionHandler();
- }
-
- /**
- * Method httpAction.
- * @param url String
- * @return HttpActionHandler.Builder
- */
- public static HttpActionHandler.Builder httpAction(String url) {
- return httpAction().url(url);
- }
-
- /**
- * Method httpAction.
- * @param url String
- * @param method String
- * @return HttpActionHandler.Builder
- */
- public static HttpActionHandler.Builder httpAction(
- String url,
- String method) {
- return httpAction()
- .url(url)
- .method(method);
- }
-
- /**
- * Method embedAction.
- * @return EmbedActionHandler.Builder
- */
- public static EmbedActionHandler.Builder embedAction() {
- return EmbedActionHandler.makeEmbedActionHandler();
- }
-
- /**
- * Method embedAction.
- * @param url String
- * @return EmbedActionHandler.Builder
- */
- public static EmbedActionHandler.Builder embedAction(String url) {
- return embedAction().url(url);
- }
-
- /**
- * Method embedAction.
- * @param url String
- * @param mediaType String
- * @return EmbedActionHandler.Builder
- */
- public static EmbedActionHandler.Builder embedAction(
- String url,
- String mediaType) {
- return embedAction(url).mediaType(mediaType);
- }
-
- /**
- * Method staticEmbedAction.
- * @param mediaType String
- * @param content String
- * @return EmbedActionHandler.Builder
- */
- public static EmbedActionHandler.Builder staticEmbedAction(
- String mediaType,
- String content) {
- return embedAction().mediaType(mediaType).content(content);
- }
-
- /**
- * Method intentAction.
- * @return IntentActionHandler.Builder
- */
- public static IntentActionHandler.Builder intentAction() {
- return IntentActionHandler.makeIntentActionHandler();
- }
-
- /**
- * Method intentAction.
- * @param url String
- * @return IntentActionHandler.Builder
- */
- public static IntentActionHandler.Builder intentAction(String url) {
- return intentAction().url(url);
- }
-
- /**
- * Method htmlForm.
- * @return HtmlForm.Builder
- */
- public static HtmlForm.Builder htmlForm() {
- return HtmlForm.makeHtmlForm();
- }
-
- /**
- * Method typedPayload.
- * @param mediaType String
- * @return TypedPayload.Builder
- */
- public static TypedPayload.Builder typedPayload(String mediaType) {
- return TypedPayload.makeTypedPayload(mediaType);
- }
-
- public static TypedPayload.Builder typedPayload() {
- return TypedPayload.make();
- }
-
- /**
- * Method urlTemplate.
- * @return UrlTemplate.Builder
- */
- public static UrlTemplate.Builder urlTemplate() {
- return UrlTemplate.makeUrlTemplate();
- }
-
- /**
- * Method urlTemplate.
- * @param template String
- * @return UrlTemplate.Builder
- */
- public static UrlTemplate.Builder urlTemplate(String template) {
- return urlTemplate().template(template);
- }
-
- /**
- * Method parameter.
- * @return Parameter.Builder
- */
- public static Parameter.Builder parameter() {
- return Parameter.makeParameter();
- }
-
- /**
- * Method parameter.
- * @param id String
- * @return Parameter.Builder
- */
- public static SimpleParameterValue parameter(String id) {
- return new SimpleParameterValue.Builder().type(id).get();
- }
-}
diff --git a/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionObjectAdapter.java b/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionObjectAdapter.java
deleted file mode 100644
index ef7de7f..0000000
--- a/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionObjectAdapter.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Copyright 2013 OpenSocial Foundation
- * Copyright 2013 International Business Machines Corporation
- *
- * Licensed 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.
- *
- * Utility library for working with Activity Streams Actions
- * Requires underscorejs.
- *
- * @author James M Snell (jasnell@us.ibm.com)
- */
-package com.ibm.common.activitystreams.actions;
-
-import java.lang.reflect.Type;
-
-import com.google.common.collect.ImmutableSet;
-import com.ibm.common.activitystreams.ASObject.AbstractBuilder;
-import com.ibm.common.activitystreams.internal.ASObjectAdapter;
-import com.ibm.common.activitystreams.internal.Model;
-import com.ibm.common.activitystreams.internal.Schema;
-
-public final class ActionObjectAdapter
- extends ASObjectAdapter {
-
- ActionObjectAdapter(Schema schema) {
- super(schema);
- }
-
- private static final ImmutableSet> knownTypes =
- ImmutableSet.>of(
- HttpActionHandler.class,
- IntentActionHandler.class,
- EmbedActionHandler.class,
- HtmlForm.class,
- UrlTemplate.class,
- TypedPayload.class
- );
-
- @Override
- protected boolean knowsType(Type type) {
- if (super.knowsType(type))
- return true;
- return knownTypes.contains(type);
- }
-
- @Override
- protected AbstractBuilder, ?> builderFor(Type type) {
- if (super.knowsType(type))
- return super.builderFor(type);
- if (type == HttpActionHandler.class)
- return ActionMakers.httpAction();
- else if (type == IntentActionHandler.class)
- return ActionMakers.intentAction();
- else if (type == EmbedActionHandler.class)
- return ActionMakers.embedAction();
- else if (type == HtmlForm.class)
- return ActionMakers.htmlForm();
- else if (type == UrlTemplate.class)
- return ActionMakers.urlTemplate();
- else if (type == TypedPayload.class)
- return ActionMakers.typedPayload();
- else return null;
- }
-
- @Override
- protected Model modelFor(Type type) {
- if (super.knowsType(type))
- return super.modelFor(type);
- if (type == HttpActionHandler.class)
- return schema().forObjectClassOrType(
- HttpActionHandler.Builder.class,
- "HttpActionHandler");
- else if (type == IntentActionHandler.class)
- return schema().forObjectClassOrType(
- IntentActionHandler.Builder.class,
- "IntentActionHandler");
- else if (type == EmbedActionHandler.class)
- return schema().forObjectClassOrType(
- EmbedActionHandler.Builder.class,
- "EmbedActionHandler");
- else if (type == HtmlForm.class)
- return schema().forObjectClassOrType(
- HtmlForm.Builder.class,
- "HtmlForm");
- else if (type == UrlTemplate.class)
- return schema().forObjectClassOrType(
- UrlTemplate.Builder.class,
- "UrlTemplate");
- else if (type == TypedPayload.class)
- return schema().forObjectClassOrType(
- TypedPayload.Builder.class,
- "TypedPayload");
- else return null;
- }
-
-}
diff --git a/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionsModule.java b/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionsModule.java
deleted file mode 100644
index 6604b8f..0000000
--- a/actions/src/main/java/com/ibm/common/activitystreams/actions/ActionsModule.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Copyright 2013 OpenSocial Foundation
- * Copyright 2013 International Business Machines Corporation
- *
- * Licensed 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.
- *
- * Utility library for working with Activity Streams Actions
- * Requires underscorejs.
- *
- * @author James M Snell (jasnell@us.ibm.com)
- */
-package com.ibm.common.activitystreams.actions;
-
-import static com.ibm.common.activitystreams.actions.Adapters.AUTH;
-import static com.ibm.common.activitystreams.actions.Adapters.STYLES;
-
-import com.ibm.common.activitystreams.IO.Builder;
-import com.ibm.common.activitystreams.internal.Model;
-import com.ibm.common.activitystreams.internal.Schema;
-import com.ibm.common.activitystreams.util.Module;
-
-public final class ActionsModule
- implements Module {
-
- public static final Module instance = new ActionsModule();
-
- @Override
- public void apply(Builder builder, Schema schema) {
-
- ActionObjectAdapter base =
- new ActionObjectAdapter(schema);
-
- // Register Adapters
- builder.hierarchicalAdapter(ActionHandler.class,base)
- .hierarchicalAdapter(HttpActionHandler.class,base)
- .hierarchicalAdapter(IntentActionHandler.class,base)
- .hierarchicalAdapter(EmbedActionHandler.class,base)
- .hierarchicalAdapter(HtmlForm.class,base)
- .hierarchicalAdapter(ParametersValue.class, ParametersAdapter.instance)
- .hierarchicalAdapter(ParameterValue.class, ParameterAdapter.instance)
- .hierarchicalAdapter(UrlTemplate.class,base)
- .hierarchicalAdapter(TypedPayload.class,base)
- .hierarchicalAdapter(Authentication.class, AUTH)
- .hierarchicalAdapter(StylesValue.class, STYLES);
- }
-
- @Override
- public void apply(Schema.Builder builder) {
- builder.map("HtmlForm", withParameters.template(HtmlForm.class, HtmlForm.Builder.class))
- .map("TypedPayload", typedPayload)
- .map("UrlTemplate", withParameters.template(UrlTemplate.class, UrlTemplate.Builder.class))
- .map("HttpActionHandler", actionHandler.template(HttpActionHandler.class, HttpActionHandler.Builder.class))
- .map("IntentActionHandler", actionHandler.template(IntentActionHandler.class, IntentActionHandler.Builder.class))
- .map("EmbedActionHandler", actionHandler.template(EmbedActionHandler.class, EmbedActionHandler.Builder.class));
- }
-
- public final static Model actionHandler =
- Model
- .make("object")
- .linkValue(
- "expects",
- "returns",
- "requires",
- "prefers")
- .object("context")
- .as("auth", Authentication.class)
- .as("style", StylesValue.class)
- .get();
-
-
- public final static Model withParameters =
- Model
- .make("object")
- .as("parameters", ParametersValue.class)
- .get();
-
- public final static Model typedPayload =
- Model
- .make("object")
- .type(TypedPayload.class, TypedPayload.Builder.class)
- .linkValue("schema")
- .typeValue("type")
- .get();
-
-
-
-}
diff --git a/actions/src/main/java/com/ibm/common/activitystreams/actions/Authentication.java b/actions/src/main/java/com/ibm/common/activitystreams/actions/Authentication.java
deleted file mode 100755
index 87be702..0000000
--- a/actions/src/main/java/com/ibm/common/activitystreams/actions/Authentication.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Copyright 2013 OpenSocial Foundation
- * Copyright 2013 International Business Machines Corporation
- *
- * Licensed 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.
- *
- * Utility library for working with Activity Streams Actions
- * Requires underscorejs.
- *
- * @author James M Snell (jasnell@us.ibm.com)
- */
-package com.ibm.common.activitystreams.actions;
-
-import java.io.Serializable;
-import java.util.Map;
-
-import com.google.common.collect.ImmutableMap;
-import com.ibm.common.activitystreams.ASObject;
-import com.ibm.common.activitystreams.util.AbstractDictionaryObject;
-
-/**
- */
-public final class Authentication
- extends AbstractDictionaryObject {
-
- /**
- * Method make.
- * @return Builder
- */
- public static Builder make() {
- return new Builder();
- }
-
- /**
- */
- public static final class Builder
- extends AbstractDictionaryObject.AbstractBuilder<
- ASObject,Authentication,Builder> {
-
- public Builder() {
- writeUsing(ActionMakers.io);
- }
-
- /**
- * Method get.
- * @return Authentication
- * @see com.google.common.base.Supplier#get()
- */
- public Authentication get() {
- return new Authentication(this);
- }
-
- }
-
- /**
- * Constructor for Authentication.
- * @param builder Builder
- */
- protected Authentication(Builder builder) {
- super(builder);
- }
-
- /**
- * Method get.
- * @param key String
- * @return A
- */
- @SuppressWarnings("unchecked")
- public A get(String key) {
- return (A)this.getSingle(key);
- }
-
- Object writeReplace() throws java.io.ObjectStreamException {
- return new SerializedForm(this);
- }
-
- private static class SerializedForm
- implements Serializable {
- private static final long serialVersionUID = -1975376657749952999L;
- private ImmutableMap map;
- SerializedForm(Authentication obj) {
- ImmutableMap.Builder builder =
- ImmutableMap.builder();
- for (String key : obj)
- builder.put(key, obj.get(key));
- this.map = builder.build();
- }
-
- Object readResolve()
- throws java.io.ObjectStreamException {
- Authentication.Builder builder =
- Authentication.make();
- for (Map.Entry entry : map.entrySet())
- builder.set(entry.getKey(), (ASObject) entry.getValue());
- return builder.get();
- }
- }
-}
diff --git a/actions/src/main/java/com/ibm/common/activitystreams/actions/EmbedActionHandler.java b/actions/src/main/java/com/ibm/common/activitystreams/actions/EmbedActionHandler.java
deleted file mode 100755
index 7e5a559..0000000
--- a/actions/src/main/java/com/ibm/common/activitystreams/actions/EmbedActionHandler.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/**
- * Copyright 2013 OpenSocial Foundation
- * Copyright 2013 International Business Machines Corporation
- *
- * Licensed 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.
- *
- * Utility library for working with Activity Streams Actions
- * Requires underscorejs.
- *
- * @author James M Snell (jasnell@us.ibm.com)
- */
-package com.ibm.common.activitystreams.actions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.getFirst;
-import static com.google.common.collect.Iterables.size;
-
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableList;
-
-/**
- */
-public class EmbedActionHandler
- extends ActionHandler
- implements Serializable {
-
- /**
- * Method makeEmbedActionHandler.
- * @return Builder
- */
- public static Builder makeEmbedActionHandler() {
- return new Builder();
- }
-
- /**
- */
- public static final class Builder
- extends AbstractBuilder {
-
- public Builder() {
- super("EmbedActionHandler");
- }
-
- /**
- * Method getActual.
- * @return EmbedActionHandler
- */
- protected EmbedActionHandler getActual() {
- return new EmbedActionHandler(this);
- }
-
- }
-
- /**
- */
- @SuppressWarnings("unchecked")
- public static abstract class AbstractBuilder>
- extends ActionHandler.Builder {
-
- private boolean styleset = false;
- private static ImmutableList.Builder styles =
- ImmutableList.builder();
-
- /**
- * Constructor for AbstractBuilder.
- * @param objectType String
- */
- protected AbstractBuilder(String objectType) {
- objectType(objectType);
- }
-
- /**
- * Method target.
- * @param target String
- * @return B
- */
- public B target(String target) {
- set("target", target);
- return (B)this;
- }
-
- /**
- * Method style.
- * @param style StylesValue
- * @return B
- */
- public B style(StylesValue style) {
- styleset = true;
- styles.add(style);
- return (B)this;
- }
-
- /**
- * Method style.
- * @param style Supplier
- * @return B
- */
- public B style(Supplier style) {
- return style(style.get());
- }
-
- /**
- * Method style.
- * @param styles StylesValue[]
- * @return B
- */
- public B style(StylesValue... styles) {
- for (StylesValue s : styles)
- style(s);
- return (B)this;
- }
-
- /**
- * Method style.
- * @param styles Supplier[]
- * @return B
- */
- public B style(Supplier... styles) {
- for (Supplier s : styles)
- style(s);
- return (B)this;
- }
-
- /**
- * Method actualGet.
- * @return A
- */
- protected final A actualGet() {
- if (styleset) {
- ImmutableList val = styles.build();
- if (size(val) == 1) {
- set("style", getFirst(val,null));
- } else {
- set("style", val);
- }
- }
- return getActual();
- }
-
- /**
- * Method getActual.
- * @return A
- */
- protected abstract A getActual();
- }
-
- /**
- * Constructor for EmbedActionHandler.
- * @param builder AbstractBuilder,?>
- */
- protected EmbedActionHandler(AbstractBuilder,?> builder) {
- super(builder);
- }
-
- /**
- * Method styles.
- * @return Iterable
- */
- @SuppressWarnings("unchecked")
- public Iterable styles() {
- Object styles = get("style");
- if (styles instanceof StylesValue)
- return ImmutableList.of((StylesValue)styles);
- else if (styles instanceof Iterable)
- return (Iterable)styles;
- else return ImmutableList.of();
- }
-
- /**
- * Method styles.
- * @param media String
- * @return Iterable
- */
- public Iterable styles(final String media) {
- checkNotNull(media);
- return styles(new Predicate() {
- public boolean apply(StylesValue style) {
- return media.equalsIgnoreCase(style.media());
- }
- });
- }
-
- /**
- * Method styles.
- * @param matcher Predicate
- * @return Iterable
- */
- public Iterable styles(Predicate matcher) {
- return filter(styles(), matcher);
- }
-
- /**
- * Method target.
- * @return String
- */
- public String target() {
- return getString(
- "target",
- ActionMakers.TARGET_DEFAULT);
- }
-
- Object writeReplace() throws java.io.ObjectStreamException {
- return new SerializedForm(this);
- }
-
- private static class SerializedForm
- extends AbstractSerializedForm {
- private static final long serialVersionUID = -2060301713159936285L;
- protected SerializedForm(EmbedActionHandler obj) {
- super(obj);
- }
- Object readResolve() throws ObjectStreamException {
- return super.doReadResolve();
- }
- protected EmbedActionHandler.Builder builder() {
- return ActionMakers.embedAction();
- }
- }
-}
diff --git a/actions/src/main/java/com/ibm/common/activitystreams/actions/HtmlForm.java b/actions/src/main/java/com/ibm/common/activitystreams/actions/HtmlForm.java
deleted file mode 100755
index b6fe0ad..0000000
--- a/actions/src/main/java/com/ibm/common/activitystreams/actions/HtmlForm.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Copyright 2013 OpenSocial Foundation
- * Copyright 2013 International Business Machines Corporation
- *
- * Licensed 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.
- *
- * Utility library for working with Activity Streams Actions
- * Requires underscorejs.
- *
- * @author James M Snell (jasnell@us.ibm.com)
- */
-package com.ibm.common.activitystreams.actions;
-
-import java.io.ObjectStreamException;
-
-import com.google.common.base.Supplier;
-import com.ibm.common.activitystreams.ASObject;
-
-/**
- */
-public final class HtmlForm
- extends ASObject {
-
- /**
- * Method makeHtmlForm.
- * @return Builder
- */
- public static Builder makeHtmlForm() {
- return new Builder();
- }
-
- /**
- */
- public static final class Builder
- extends ASObject.AbstractBuilder {
-
- private final ParametersValue.Builder params =
- ParametersValue.make();
-
- public Builder() {
- writeUsing(ActionMakers.io);
- objectType("HtmlForm");
- mediaType("application/x-www-form-urlencoded");
- }
-
- public Builder parameter(String name, String iri) {
- params.param(name, iri);
- return this;
- }
-
- public Builder parameter(
- String name,
- ParameterValue parameter) {
- params.param(name, parameter);
- return this;
- }
-
- public Builder parameter(
- String name,
- Supplier extends ParameterValue> parameter) {
- return parameter(name, parameter.get());
- }
-
- /**
- * Method get.
- * @return HtmlForm
- * @see com.google.common.base.Supplier#get()
- */
- public HtmlForm get() {
- if (params.notEmpty())
- set("parameters", params.get());
- return new HtmlForm(this);
- }
-
- }
-
- /**
- * Constructor for HtmlForm.
- * @param builder Builder
- */
- private HtmlForm(Builder builder) {
- super(builder);
- }
-
- /**
- * Method parameters.
- * @return ParametersValue
- */
- public ParametersValue parameters() {
- return this.get("parameters");
- }
-
- Object writeReplace() throws java.io.ObjectStreamException {
- return new SerializedForm(this);
- }
-
- private static class SerializedForm
- extends AbstractSerializedForm {
- private static final long serialVersionUID = -2060301713159936285L;
- protected SerializedForm(HtmlForm obj) {
- super(obj);
- }
- Object readResolve() throws ObjectStreamException {
- return super.doReadResolve();
- }
- protected HtmlForm.Builder builder() {
- return ActionMakers.htmlForm();
- }
- }
-}
diff --git a/actions/src/main/java/com/ibm/common/activitystreams/actions/HttpActionHandler.java b/actions/src/main/java/com/ibm/common/activitystreams/actions/HttpActionHandler.java
deleted file mode 100755
index 6993011..0000000
--- a/actions/src/main/java/com/ibm/common/activitystreams/actions/HttpActionHandler.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * Copyright 2013 OpenSocial Foundation
- * Copyright 2013 International Business Machines Corporation
- *
- * Licensed 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.
- *
- * Utility library for working with Activity Streams Actions
- * Requires underscorejs.
- *
- * @author James M Snell (jasnell@us.ibm.com)
- */
-package com.ibm.common.activitystreams.actions;
-
-import java.io.ObjectStreamException;
-
-
-/**
- */
-public class HttpActionHandler
- extends ActionHandler {
-
- /**
- * Method makeHttpActionHandler.
- * @return Builder
- */
- public static Builder makeHttpActionHandler() {
- return new Builder();
- }
-
- /**
- */
- public static final class Builder
- extends AbstractBuilder {
-
- public Builder() {
- super("HttpActionHandler");
- }
-
- /**
- * Method actualGet.
- * @return HttpActionHandler
- */
- protected HttpActionHandler actualGet() {
- return new HttpActionHandler(this);
- }
-
- }
-
- /**
- */
- @SuppressWarnings("unchecked")
- public static abstract class AbstractBuilder
- >
- extends ActionHandler.Builder {
- /**
- * Constructor for AbstractBuilder.
- * @param objectType String
- */
- protected AbstractBuilder(String objectType) {
- objectType(objectType);
- }
-
- /**
- * Method method.
- * @param method String
- * @return B
- */
- public B method(String method) {
- set("method", method);
- return (B)this;
- }
-
- /**
- * Method target.
- * @param target String
- * @return B
- */
- public B target(String target) {
- set("target", target);
- return (B)this;
- }
- }
-
- /**
- * Constructor for HttpActionHandler.
- * @param builder AbstractBuilder,?>
- */
- protected HttpActionHandler(AbstractBuilder,?> builder) {
- super(builder);
- }
-
- /**
- * Method method.
- * @return String
- */
- public String method() {
- return this.getString("method");
- }
-
- /**
- * Method target.
- * @return String
- */
- public String target() {
- return has("target") ?
- this.get("target") :
- ActionMakers.TARGET_DEFAULT;
- }
-
- Object writeReplace() throws java.io.ObjectStreamException {
- return new SerializedForm(this);
- }
-
- private static class SerializedForm
- extends AbstractSerializedForm {
- private static final long serialVersionUID = -2060301713159936285L;
- protected SerializedForm(HttpActionHandler obj) {
- super(obj);
- }
- Object readResolve() throws ObjectStreamException {
- return super.doReadResolve();
- }
- protected HttpActionHandler.Builder builder() {
- return ActionMakers.httpAction();
- }
- }
-}
diff --git a/actions/src/main/java/com/ibm/common/activitystreams/actions/IntentActionHandler.java b/actions/src/main/java/com/ibm/common/activitystreams/actions/IntentActionHandler.java
deleted file mode 100755
index ab8eee4..0000000
--- a/actions/src/main/java/com/ibm/common/activitystreams/actions/IntentActionHandler.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * Copyright 2013 OpenSocial Foundation
- * Copyright 2013 International Business Machines Corporation
- *
- * Licensed 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.
- *
- * Utility library for working with Activity Streams Actions
- * Requires underscorejs.
- *
- * @author James M Snell (jasnell@us.ibm.com)
- */
-package com.ibm.common.activitystreams.actions;
-
-import java.io.ObjectStreamException;
-
-
-/**
- */
-public class IntentActionHandler
- extends ActionHandler {
-
- /**
- * Method makeIntentActionHandler.
- * @return Builder
- */
- public static Builder makeIntentActionHandler() {
- return new Builder();
- }
-
- /**
- */
- public static final class Builder
- extends AbstractBuilder {
-
- public Builder() {
- super("IntentActionHandler");
- }
-
- /**
- * Method actualGet.
- * @return IntentActionHandler
- */
- protected IntentActionHandler actualGet() {
- return new IntentActionHandler(this);
- }
-
- }
-
- /**
- */
- public static abstract class AbstractBuilder
- >
- extends ActionHandler.Builder {
- /**
- * Constructor for AbstractBuilder.
- * @param objectType String
- */
- protected AbstractBuilder(String objectType) {
- objectType(objectType);
- }
- }
-
- /**
- * Constructor for IntentActionHandler.
- * @param builder AbstractBuilder,?>
- */
- protected IntentActionHandler(AbstractBuilder,?> builder) {
- super(builder);
- }
-
- Object writeReplace() throws java.io.ObjectStreamException {
- return new SerializedForm(this);
- }
-
- private static class SerializedForm
- extends AbstractSerializedForm {
- private static final long serialVersionUID = -2060301713159936285L;
- protected SerializedForm(IntentActionHandler obj) {
- super(obj);
- }
- Object readResolve() throws ObjectStreamException {
- return super.doReadResolve();
- }
- protected IntentActionHandler.Builder builder() {
- return ActionMakers.intentAction();
- }
- }
-}
diff --git a/actions/src/main/java/com/ibm/common/activitystreams/actions/Parameter.java b/actions/src/main/java/com/ibm/common/activitystreams/actions/Parameter.java
deleted file mode 100755
index d692442..0000000
--- a/actions/src/main/java/com/ibm/common/activitystreams/actions/Parameter.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/**
- * Copyright 2013 OpenSocial Foundation
- * Copyright 2013 International Business Machines Corporation
- *
- * Licensed 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.
- *
- * Utility library for working with Activity Streams Actions
- * Requires underscorejs.
- *
- * @author James M Snell (jasnell@us.ibm.com)
- */
-package com.ibm.common.activitystreams.actions;
-
-import static com.ibm.common.activitystreams.Makers.nlv;
-import static com.ibm.common.activitystreams.util.Util.DEFAULT_LOCALE;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Supplier;
-import com.google.common.collect.BoundType;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Ordering;
-import com.google.common.collect.Range;
-import com.ibm.common.activitystreams.Makers;
-import com.ibm.common.activitystreams.NLV;
-import com.ibm.common.activitystreams.ValueType;
-import com.ibm.common.activitystreams.NLV.MapNLV;
-import com.ibm.common.activitystreams.NLV.SimpleNLV;
-import com.ibm.common.activitystreams.util.AbstractWritable;
-
-@SuppressWarnings("unchecked")
-public class Parameter
- extends AbstractWritable
- implements ParameterValue {
-
- /**
- * Method makeParameter.
- * @return Builder
- */
- public static Builder makeParameter() {
- return new Builder();
- }
-
- public static class Builder
- extends AbstractWritable.AbstractWritableBuilder {
-
- protected Builder() {
- writeUsing(ActionMakers.io);
- }
-
- private final Map map =
- Maps.newHashMap();
-
- public Builder language(String lang) {
- if (lang != null)
- map.put("language", lang);
- else
- map.remove("language");
- return this;
- }
-
- protected Builder _nlv(String key, String value) {
- if (value != null)
- map.put(key, nlv(value));
- else
- map.remove(key);
- return this;
- }
-
- protected Builder _nlv(String key, NLV nlv) {
- if (nlv != null)
- map.put(key, nlv);
- else
- map.remove(key);
- return this;
- }
-
- protected Builder _nlv(String key, Supplier extends NLV> nlv) {
- return _nlv(key,nlv.get());
- }
-
- protected Builder _nlv(String key, Map map) {
- if (map != null)
- for (Map.Entry entry : map.entrySet())
- _nlv(key,entry.getKey(),entry.getValue());
- else
- this.map.remove(key);
- return this;
- }
-
- protected Builder _nlv(String key, String lang, String value) {
- if (map.containsKey(key)) {
- Object obj = map.get(key);
- if (obj instanceof NLV) {
- NLV nlv = (NLV) obj;
- switch(nlv.valueType()) {
- case SIMPLE:
- String l = (String) map.get("language");
- if (l == null)
- l = DEFAULT_LOCALE;
- NLV.MapNLV.Builder b =
- Makers.nlv();
- if (lang.equals(l))
- b.set(lang, value);
- else
- b.set(l, ((NLV.SimpleNLV)obj).value())
- .set(lang, value);
- map.put(key, b);
- return this;
- case OBJECT:
- map.put(key,
- Makers.nlv()
- .from((NLV.MapNLV)obj, lang)
- .set(lang, value));
- return this;
- default:
- throw new IllegalArgumentException();
- }
- } else if (obj instanceof NLV.MapNLV.Builder) {
- ((NLV.MapNLV.Builder) obj).set(lang, value);
- return this;
- }
- }
- map.put(key, Makers.nlv().set(lang,value));
- return this;
- }
-
- public Builder displayName(String val) {
- return _nlv("displayName",val);
- }
-
- public Builder displayName(NLV nlv) {
- return _nlv("displayName", nlv);
- }
-
- public Builder displayName(Supplier extends NLV> nlv) {
- return _nlv("displayName", nlv);
- }
-
- public Builder displayName(String lang, String val) {
- return _nlv("displayName", lang, val);
- }
-
- public Builder placeholder(String placeholder) {
- return _nlv("placeholder", placeholder);
- }
-
- public Builder placeholder(NLV placeholder) {
- return _nlv("placeholder", placeholder);
- }
-
- public Builder placeholder(Supplier extends NLV> nlv) {
- return _nlv("placeholder", nlv);
- }
-
- public Builder placeholder(String lang, String val) {
- return _nlv("placeholder", lang, val);
- }
-
- public Builder type(String type) {
- if (type != null)
- map.put("type", type);
- else
- map.remove("type");
- return this;
- }
-
- public Builder required() {
- map.remove("required");
- return this;
- }
-
- public Builder optional() {
- map.put("required", false);
- return this;
- }
-
- public Builder repeated() {
- map.put("repeated", true);
- return this;
- }
-
- public Builder notRepeated() {
- map.remove("repeated");
- return this;
- }
-
- public Builder value(Object value) {
- if (value != null)
- map.put("value", value);
- else
- map.remove("value");
- return this;
- }
-
- public Builder defaultValue(Object value) {
- if (value != null)
- map.put("default", value);
- else
- map.remove("default");
- return this;
- }
-
- public Builder pattern(Pattern... pattern) {
- if (pattern != null && pattern.length > 0) {
- ImmutableSet.Builder patterns =
- ImmutableSet.builder();
- for (Pattern p : pattern)
- patterns.add(p.pattern());
- map.put("pattern",patterns.build());
- } else {
- map.remove("pattern");
- }
- return this;
- }
-
- public Builder pattern(String... pattern) {
- if (pattern != null && pattern.length > 0) {
- ImmutableSet patterns =
- ImmutableSet.copyOf(pattern);
- map.put("pattern",patterns);
- } else {
- map.remove("pattern");
- }
- return this;
- }
-
- public Builder pattern(Iterable patterns) {
- if (patterns != null && Iterables.size(patterns) > 0) {
- map.put("pattern", ImmutableSet.copyOf(patterns));
- } else
- map.remove("pattern");
- return this;
- }
-
- public Builder minInclusive(Object min) {
- if (min != null)
- map.put("minInclusive", min);
- else
- map.remove("minInclusive");
- return this;
- }
-
- public Builder minExclusive(Object min) {
- if (min != null)
- map.put("minExclusive", min);
- else
- map.remove("minExclusive");
- return this;
- }
-
- public Builder maxInclusive(Object max) {
- if (max != null)
- map.put("maxInclusive", max);
- else
- map.remove("maxInclusive");
- return this;
- }
-
- public Builder maxExclusive(Object max) {
- if (max != null)
- map.put("maxExclusive", max);
- else
- map.remove("maxExclusive");
- return this;
- }
-
- public Builder bound(Range> range) {
- if (range != null) {
- if (range.hasLowerBound()) {
- switch(range.lowerBoundType()) {
- case CLOSED:
- minInclusive(range.lowerEndpoint());
- break;
- case OPEN:
- minExclusive(range.lowerEndpoint());
- break;
- default:
- break;
- }
- } else {
- minInclusive(null);
- minExclusive(null);
- }
- if (range.hasUpperBound()) {
- switch(range.upperBoundType()) {
- case CLOSED:
- maxInclusive(range.upperEndpoint());
- break;
- case OPEN:
- maxExclusive(range.upperEndpoint());
- break;
- default:
- break;
- }
- } else {
- maxInclusive(null);
- maxExclusive(null);
- }
- }
- return this;
- }
-
- public Builder step(Number step) {
- if (step != null)
- map.put("step", step);
- else
- map.remove("step");
- return this;
- }
-
- public Builder enumeration(Object... vals) {
- if (vals != null && vals.length > 0)
- map.put("enumeration", ImmutableList.copyOf(vals));
- else
- map.remove("enumeration");
- return this;
- }
-
- public Builder maxLength(int length) {
- if (length > -1)
- map.put("maxLength", length);
- else
- map.remove("maxLength");
- return this;
- }
-
- public Builder minLength(int length) {
- if (length > -1)
- map.put("minLength", length);
- else
- map.remove("minLength");
- return this;
- }
-
- public Builder totalDigits(int num) {
- if (num > -1)
- map.put("totalDigits", num);
- else
- map.remove("totalDigits");
- return this;
- }
-
- public Builder fractionDigits(int num) {
- if (num > -1)
- map.put("fractionDigits", num);
- else
- map.remove("fractionDigits");
- return this;
- }
-
- public Parameter get() {
- return new Parameter(this);
- }
-
- }
-
- private final ImmutableMap map;
-
- /**
- * Constructor for Parameter.
- * @param builder Builder
- */
- protected Parameter(Builder builder) {
- super(builder);
- this.map = ImmutableMap.copyOf(builder.map);
- }
-
- /**
- * Method required.
- * @return boolean
- */
- public boolean required() {
- return !has("required") ?
- true : (Boolean)map.get("required");
- }
-
- /**
- * Method repeated.
- * @return boolean
- */
- public boolean repeated() {
- return !has("repeated") ?
- false : (Boolean)map.get("repeated");
- }
-
- /**
- * Method value.
- * @return O
- */
- public O value() {
- return (O)map.get("value");
- }
-
- /**
- * Method value.
- * @param defaultValue O
- * @return O
- */
- public O value(O defaultValue) {
- O val = value();
- return val != null ? val : defaultValue;
- }
-
- /**
- * Method defaultValue.
- * @return O
- */
- public O defaultValue() {
- return (O)map.get("default");
- }
-
- /**
- * Method defaultValue.
- * @param defaultValue O
- * @return O
- */
- public O defaultValue(O defaultValue) {
- O val = defaultValue();
- return val != null ? val : defaultValue;
- }
-
- public String type() {
- return (String)map.get("type");
- }
-
- /**
- * Method pattern.
- * @return String
- */
- public Iterable pattern() {
- return (Iterable)map.get("pattern");
- }
-
- public O maxInclusive() {
- return (O)map.get("maxInclusive");
- }
-
- public O maxExclusive() {
- return (O)map.get("maxExclusive");
- }
-
- public O minInclusive() {
- return (O)map.get("minInclusive");
- }
-
- public O minExclusive() {
- return (O)map.get("minExclusive");
- }
-
- public boolean has(String key) {
- return map.containsKey(key);
- }
-
- public boolean hasUpperBound() {
- return has("maxInclusive") || has("maxExclusive");
- }
-
- public >Range bounds() {
- O mini = minInclusive();
- O mine = minExclusive();
- O maxi = maxInclusive();
- O maxe = maxExclusive();
- Ordering ordering = Ordering.natural();
- O min = ordering.nullsLast().min(mini,mine);
- O max = ordering.nullsFirst().max(maxi,maxe);
- BoundType lower =
- min == null ? null :
- min == mini ? BoundType.CLOSED :
- BoundType.OPEN;
- BoundType upper =
- max == null ? null :
- max == maxi ? BoundType.CLOSED :
- BoundType.OPEN;
- if (lower == null && upper == null)
- return Range.all();
- else if (lower != null && upper == null)
- return lower == BoundType.CLOSED ?
- Range.atLeast(min) :
- Range.greaterThan(min);
- else if (lower == null && upper != null)
- return upper == BoundType.CLOSED ?
- Range.atMost(max) :
- Range.lessThan(max);
- else {
- return Range.range(min, lower, max, upper);
- }
- }
-
- public N step() {
- return (N)map.get("step");
- }
-
- public N step(N defaultValue) {
- N n = (N)map.get("step");
- return n != null ? n : defaultValue;
- }
-
- /**
- * Method stepInt.
- * @return int
- */
- public int stepInt() {
- return step();
- }
-
- /**
- * Method stepInt.
- * @param defaultValue int
- * @return int
- */
- public int stepInt(int defaultValue) {
- return step(defaultValue);
- }
-
- /**
- * Method stepLong.
- * @return long
- */
- public long stepLong() {
- return step();
- }
-
- /**
- * Method getLong.
- * @param defaultValue long
- * @return long
- */
- public long stepLong(long defaultValue) {
- return step(defaultValue);
- }
-
- /**
- * Method stepShort.
- * @return short
- */
- public short stepShort() {
- return step();
- }
-
- /**
- * Method stepShort.
- * @param defaultValue short
- * @return short
- */
- public short stepShort(short defaultValue) {
- return step(defaultValue);
- }
-
- /**
- * Method stepDouble.
- * @return double
- */
- public double stepDouble() {
- return step();
- }
-
- /**
- * Method stepDouble.
- * @param defaultValue double
- * @return double
- */
- public double stepDouble(double defaultValue) {
- return step(defaultValue);
- }
-
- /**
- * Method stepFloat.
- * @return float
- */
- public float stepFloat() {
- return step();
- }
-
- /**
- * Method stepFloat.
- * @param defaultValue float
- * @return float
- */
- public float stepFloat(float defaultValue) {
- return step(defaultValue);
- }
-
- /**
- * Method enumVals.
- * @return Iterable