From cd5680917559da8403006ae70e2af34a6f48b4a5 Mon Sep 17 00:00:00 2001 From: rodionmoiseev Date: Sat, 24 Nov 2012 22:24:30 +0900 Subject: [PATCH] API for extracting all bundle keys from all c10n enabled interfaces (issue #12) * Use reflections library to scan for interfaces annotated with @C10NMessages, and apply bundle key extraction, returning the complete set of all keys. * Added C10NTools class, as the main entry point to tooling API * Refactoring * Added test dependency from tools -> core --- .../main/java/c10n/DefaultC10NConfigBase.java | 28 ---- .../java/c10n/share/utils/BundleKeyUtils.java | 5 + tools/build.gradle | 10 +- tools/src/main/java/c10n/tools/C10NTools.java | 47 +++++++ .../tools/search/C10NBundleKeySearch.java | 41 ++++++ .../tools/search/C10NInterfaceSearch.java | 3 +- .../search/DefaultC10NBundleKeySearch.java | 48 +++++++ .../search/DefaultC10NInterfaceSearch.java | 70 +++++----- ...erfacesSearches.java => SearchModule.java} | 24 ++-- tools/src/test/java/c10n/tools/AllTests.java | 34 +++++ .../test/java/c10n/tools/search/AllTests.java | 34 +++++ .../tools/search/C10NInterfaceSearchTest.java | 47 ++++--- .../DefaultC10NBundleKeySearchTest.java | 126 ++++++++++++++++++ .../java/c10n/tools/search/test1/Buttons.java | 11 +- .../java/c10n/tools/search/test1/Window.java | 12 +- .../tools/search/test1/labels/Labels.java | 2 +- .../tools/search/test1/labels/Labels1.java | 10 +- .../tools/search/test1/labels/Labels2.java | 6 +- 18 files changed, 441 insertions(+), 117 deletions(-) delete mode 100755 core/src/main/java/c10n/DefaultC10NConfigBase.java create mode 100755 tools/src/main/java/c10n/tools/C10NTools.java create mode 100755 tools/src/main/java/c10n/tools/search/C10NBundleKeySearch.java create mode 100755 tools/src/main/java/c10n/tools/search/DefaultC10NBundleKeySearch.java rename tools/src/main/java/c10n/tools/search/{C10NInterfacesSearches.java => SearchModule.java} (58%) create mode 100755 tools/src/test/java/c10n/tools/AllTests.java create mode 100755 tools/src/test/java/c10n/tools/search/AllTests.java create mode 100755 tools/src/test/java/c10n/tools/search/DefaultC10NBundleKeySearchTest.java diff --git a/core/src/main/java/c10n/DefaultC10NConfigBase.java b/core/src/main/java/c10n/DefaultC10NConfigBase.java deleted file mode 100755 index 5a42cf9..0000000 --- a/core/src/main/java/c10n/DefaultC10NConfigBase.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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 c10n; - -@SuppressWarnings("UnusedDeclaration") -//rationale: public API -class DefaultC10NConfigBase extends C10NConfigBase { - @Override - public void configure() { - } -} diff --git a/core/src/main/java/c10n/share/utils/BundleKeyUtils.java b/core/src/main/java/c10n/share/utils/BundleKeyUtils.java index 734b3fc..82b92b0 100755 --- a/core/src/main/java/c10n/share/utils/BundleKeyUtils.java +++ b/core/src/main/java/c10n/share/utils/BundleKeyUtils.java @@ -20,6 +20,7 @@ package c10n.share.utils; import java.lang.reflect.Method; +import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -39,6 +40,10 @@ public static Set allBundleKeys(Class... c10nInterfaces) { } public static Set allBundleKeys(String globalPrefix, Class... c10nInterfaces) { + return allBundleKeys(globalPrefix, Arrays.asList(c10nInterfaces)); + } + + public static Set allBundleKeys(String globalPrefix, Iterable> c10nInterfaces) { Set res = new HashSet(); for (Class c10nInterface : c10nInterfaces) { for (Method method : c10nInterface.getDeclaredMethods()) { diff --git a/tools/build.gradle b/tools/build.gradle index 9a51b97..4b64a4f 100755 --- a/tools/build.gradle +++ b/tools/build.gradle @@ -21,8 +21,10 @@ apply plugin: 'application' mainClassName = 'c10n.tools.codegen.Main' -dependencies{ - compile project(':core') - compile group: "org.reflections", name: "reflections", version: "0.9.8" - compile group: "com.google.code.javaparser", name: "javaparser", version: "1.0.8" +dependencies { + compile project(':core') + compile group: "org.reflections", name: "reflections", version: "0.9.8" + compile group: "com.google.code.javaparser", name: "javaparser", version: "1.0.8" + + testCompile project(':core').sourceSets.test.output } diff --git a/tools/src/main/java/c10n/tools/C10NTools.java b/tools/src/main/java/c10n/tools/C10NTools.java new file mode 100755 index 0000000..4615b83 --- /dev/null +++ b/tools/src/main/java/c10n/tools/C10NTools.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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 c10n.tools; + +import c10n.tools.search.C10NBundleKeySearch; +import c10n.tools.search.SearchModule; + +/** + * @author rodion + */ +public final class C10NTools { + /** + *

Creates new bundle key search implementation instance.

+ * + * @return bundle key search module implementation (not null) + */ + public static C10NBundleKeySearch bundleKeySearch() { + return bundleKeySearch(""); + } + + /** + *

Creates new bundle key search implementation instance.

+ * + * @param keyPrefix global bundle key prefix to use (not null) + * @return bundle key search module implementation (not null) + */ + public static C10NBundleKeySearch bundleKeySearch(String keyPrefix) { + return SearchModule.reflectionsBundleKeySearch(keyPrefix); + } +} diff --git a/tools/src/main/java/c10n/tools/search/C10NBundleKeySearch.java b/tools/src/main/java/c10n/tools/search/C10NBundleKeySearch.java new file mode 100755 index 0000000..a853c8b --- /dev/null +++ b/tools/src/main/java/c10n/tools/search/C10NBundleKeySearch.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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 c10n.tools.search; + +import c10n.share.utils.C10NBundleKey; + +/** + *

Extracts all c10n bundle keys for a given set of + * c10n interface classes.

+ * + * @author rodion + */ +public interface C10NBundleKeySearch { + /** + *

Retrieve all c10n bundle keys for inspection, from the current classpath. + * Only the packages starting with the given package prefix(es) will be included + * in search results.

+ *

Packages will be searched recursively into sub-packages, for each prefix.

+ * + * @param packagePrefixes prefixes of packages to search (not null) + * @return a collection of all matching bundle keys (not null) + */ + Iterable findAllKeys(String... packagePrefixes); +} \ No newline at end of file diff --git a/tools/src/main/java/c10n/tools/search/C10NInterfaceSearch.java b/tools/src/main/java/c10n/tools/search/C10NInterfaceSearch.java index 238f11b..4ad3f51 100755 --- a/tools/src/main/java/c10n/tools/search/C10NInterfaceSearch.java +++ b/tools/src/main/java/c10n/tools/search/C10NInterfaceSearch.java @@ -23,6 +23,5 @@ import java.util.Set; public interface C10NInterfaceSearch { - Set> find(String packagePrefix, - Class annotationClass); + Set> find(Class annotationClass, String... packagePrefixes); } diff --git a/tools/src/main/java/c10n/tools/search/DefaultC10NBundleKeySearch.java b/tools/src/main/java/c10n/tools/search/DefaultC10NBundleKeySearch.java new file mode 100755 index 0000000..60f9d84 --- /dev/null +++ b/tools/src/main/java/c10n/tools/search/DefaultC10NBundleKeySearch.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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 c10n.tools.search; + +import c10n.C10NMessages; +import c10n.share.utils.BundleKeyUtils; +import c10n.share.utils.C10NBundleKey; +import com.google.common.collect.Lists; + +import java.util.List; +import java.util.Set; + +/** + * @author rodion + */ +class DefaultC10NBundleKeySearch implements C10NBundleKeySearch { + private final C10NInterfaceSearch c10NInterfaceSearch; + private final String keyPrefix; + + DefaultC10NBundleKeySearch(C10NInterfaceSearch c10NInterfaceSearch, String keyPrefix) { + this.c10NInterfaceSearch = c10NInterfaceSearch; + this.keyPrefix = keyPrefix; + } + + @Override + public Iterable findAllKeys(String... packagePrefixes) { + List res = Lists.newArrayList(); + Set> c10nInterfaces = c10NInterfaceSearch.find(C10NMessages.class, packagePrefixes); + return BundleKeyUtils.allBundleKeys(keyPrefix, c10nInterfaces); + } +} diff --git a/tools/src/main/java/c10n/tools/search/DefaultC10NInterfaceSearch.java b/tools/src/main/java/c10n/tools/search/DefaultC10NInterfaceSearch.java index 57eb3c4..d35b42b 100755 --- a/tools/src/main/java/c10n/tools/search/DefaultC10NInterfaceSearch.java +++ b/tools/src/main/java/c10n/tools/search/DefaultC10NInterfaceSearch.java @@ -19,44 +19,48 @@ package c10n.tools.search; -import java.lang.annotation.Annotation; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Set; - +import com.google.common.base.Function; +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; import org.reflections.Reflections; -import org.reflections.scanners.SubTypesScanner; -import org.reflections.scanners.TypeAnnotationsScanner; import org.reflections.util.ClasspathHelper; import org.reflections.util.ConfigurationBuilder; import org.reflections.util.FilterBuilder; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; +import java.lang.annotation.Annotation; +import java.net.URL; +import java.util.Arrays; +import java.util.Set; class DefaultC10NInterfaceSearch implements C10NInterfaceSearch { - private final Set cp; - - DefaultC10NInterfaceSearch() { - this(ClasspathHelper.forJavaClassPath()); - } - - DefaultC10NInterfaceSearch(Set cp) { - this.cp = cp; - } - - @Override - public Set> find(String packagePrefix, Class annotationClass) { - final Predicate filter = new FilterBuilder.Include( - FilterBuilder.prefix(packagePrefix)); - Reflections reflections = new Reflections(new ConfigurationBuilder() - .setUrls(cp) - .filterInputsBy(filter) - .setScanners( - new TypeAnnotationsScanner().filterResultsBy(filter), - new SubTypesScanner().filterResultsBy(filter))); - Set types = reflections.getStore().getTypesAnnotatedWith(annotationClass.getName()); - URL[] urls = cp.toArray(new URL[cp.size()]); - return ImmutableSet.copyOf(Reflections.forNames(types, new URLClassLoader(urls))); - } + @Override + public Set> find(Class annotationClass, String... packagePrefixes) { + return new Reflections(new ConfigurationBuilder() + .filterInputsBy(getPackageInputFilter()) + .setUrls(getPackageURLs(packagePrefixes))) + .getTypesAnnotatedWith(annotationClass); + } + + + private Set getPackageURLs(String... packagePrefixes) { + Iterable packages = Iterables.concat(Iterables.transform( + Arrays.asList(packagePrefixes), new Function>() { + @Override + public Set apply(String prefix) { + return ClasspathHelper.forPackage(prefix); + } + })); + + return Sets.newHashSet(packages); + } + + private FilterBuilder getPackageInputFilter(String... packagePrefixes) { + final FilterBuilder inputFilter = new FilterBuilder(); + + for (String prefix : packagePrefixes) { + inputFilter.include(FilterBuilder.prefix(prefix)); + } + + return inputFilter; + } } diff --git a/tools/src/main/java/c10n/tools/search/C10NInterfacesSearches.java b/tools/src/main/java/c10n/tools/search/SearchModule.java similarity index 58% rename from tools/src/main/java/c10n/tools/search/C10NInterfacesSearches.java rename to tools/src/main/java/c10n/tools/search/SearchModule.java index dc1cfb9..47aa403 100755 --- a/tools/src/main/java/c10n/tools/search/C10NInterfacesSearches.java +++ b/tools/src/main/java/c10n/tools/search/SearchModule.java @@ -19,15 +19,19 @@ package c10n.tools.search; -import java.net.URL; -import java.util.Set; +public final class SearchModule { + public static C10NInterfaceSearch reflectionsSearch() { + return new DefaultC10NInterfaceSearch(); + } -public final class C10NInterfacesSearches { - public static C10NInterfaceSearch reflectionsSearch(Set urls){ - return new DefaultC10NInterfaceSearch(urls); - } - - public static C10NInterfaceSearch reflectionsSearch(){ - return new DefaultC10NInterfaceSearch(); - } + /** + *

Bundle key search implementation based on the + * Reflections library.

+ * + * @param keyPrefix global bundle key prefix to use + * @return bundle key search module implementation (not null) + */ + public static C10NBundleKeySearch reflectionsBundleKeySearch(String keyPrefix) { + return new DefaultC10NBundleKeySearch(reflectionsSearch(), keyPrefix); + } } diff --git a/tools/src/test/java/c10n/tools/AllTests.java b/tools/src/test/java/c10n/tools/AllTests.java new file mode 100755 index 0000000..08ce489 --- /dev/null +++ b/tools/src/test/java/c10n/tools/AllTests.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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 c10n.tools; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author rodion + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + c10n.AllTests.class, + c10n.tools.search.AllTests.class +}) +public class AllTests { +} \ No newline at end of file diff --git a/tools/src/test/java/c10n/tools/search/AllTests.java b/tools/src/test/java/c10n/tools/search/AllTests.java new file mode 100755 index 0000000..a8862aa --- /dev/null +++ b/tools/src/test/java/c10n/tools/search/AllTests.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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 c10n.tools.search; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author rodion + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + C10NInterfaceSearchTest.class, + DefaultC10NBundleKeySearchTest.class +}) +public class AllTests { +} diff --git a/tools/src/test/java/c10n/tools/search/C10NInterfaceSearchTest.java b/tools/src/test/java/c10n/tools/search/C10NInterfaceSearchTest.java index 6e8859a..7f22ec5 100755 --- a/tools/src/test/java/c10n/tools/search/C10NInterfaceSearchTest.java +++ b/tools/src/test/java/c10n/tools/search/C10NInterfaceSearchTest.java @@ -19,37 +19,36 @@ package c10n.tools.search; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import org.junit.Test; - import c10n.C10NMessages; import c10n.tools.search.test1.Buttons; import c10n.tools.search.test1.Window; import c10n.tools.search.test1.labels.Labels; import c10n.tools.search.test1.labels.Labels1; import c10n.tools.search.test1.labels.Labels2; +import org.junit.Test; -public class C10NInterfaceSearchTest { - private final C10NInterfaceSearch s = new DefaultC10NInterfaceSearch(); +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; - @Test - @SuppressWarnings("unchecked") - public void retrieveAllInterfaceAndSubInterfaceMethodsAsKeys() { - Set> c10nInterfaces = s.find("c10n.tools.search.test1", C10NMessages.class); - assertThat(c10nInterfaces, is(set(Window.class,// - Buttons.class,// - Labels.class,// - Labels1.class,// - Labels2.class))); - } +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; - private static Set set(E... args) { - return new HashSet(Arrays.asList(args)); - } +public class C10NInterfaceSearchTest { + private final C10NInterfaceSearch s = new DefaultC10NInterfaceSearch(); + + @Test + @SuppressWarnings("unchecked") + public void retrieveAllInterfaceAndSubInterfaceMethodsAsKeys() { + Set> c10nInterfaces = s.find(C10NMessages.class, "c10n.tools.search.test1"); + assertThat(c10nInterfaces, is(set(Window.class,// + Buttons.class,// + Labels.class,// + Labels1.class,// + Labels2.class))); + } + + private static Set set(E... args) { + return new HashSet(Arrays.asList(args)); + } } diff --git a/tools/src/test/java/c10n/tools/search/DefaultC10NBundleKeySearchTest.java b/tools/src/test/java/c10n/tools/search/DefaultC10NBundleKeySearchTest.java new file mode 100755 index 0000000..3d1c4ab --- /dev/null +++ b/tools/src/test/java/c10n/tools/search/DefaultC10NBundleKeySearchTest.java @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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 c10n.tools.search; + +import c10n.share.utils.C10NBundleKey; +import c10n.tools.search.test1.Buttons; +import c10n.tools.search.test1.Window; +import c10n.tools.search.test1.labels.Labels1; +import c10n.tools.search.test1.labels.Labels2; +import org.junit.Test; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +/** + * @author rodion + */ +public class DefaultC10NBundleKeySearchTest { + @Test + public void c10nInterfaceSearchIntegration() { + C10NBundleKeySearch bundleKeySearch = new DefaultC10NBundleKeySearch(new DefaultC10NInterfaceSearch(), ""); + assertThat(simpleKeys(bundleKeySearch.findAllKeys("c10n.tools.search.test1")), is(set( + k(Window.class, "window.title"), + k(Window.class, "window.author"), + k(Buttons.class, "buttons.ok"), + k(Buttons.class, "buttons.cancel"), + k(Labels1.class, "labels.oops"), + k(Labels1.class, "labels.label1"), + k(Labels2.class, "labels.label2") + ))); + } + + @Test + public void c10nInterfaceSearchIntegrationWithGlobalPrefix() { + C10NBundleKeySearch bundleKeySearch = new DefaultC10NBundleKeySearch( + new DefaultC10NInterfaceSearch(), + "prefix"); + assertThat(simpleKeys(bundleKeySearch.findAllKeys("c10n.tools.search.test1")), is(set( + k(Window.class, "prefix.window.title"), + k(Window.class, "prefix.window.author"), + k(Buttons.class, "prefix.buttons.ok"), + k(Buttons.class, "prefix.buttons.cancel"), + k(Labels1.class, "prefix.labels.oops"), + k(Labels1.class, "prefix.labels.label1"), + k(Labels2.class, "prefix.labels.label2") + ))); + } + + private static Set simpleKeys(Iterable bundleKeys) { + Set res = new HashSet(); + for (C10NBundleKey bundleKey : bundleKeys) { + res.add(new SimpleKey(bundleKey.getDeclaringInterface(), bundleKey.getKey())); + } + return res; + } + + private static Set set(SimpleKey... keys) { + Set res = new HashSet(); + Collections.addAll(res, keys); + return res; + } + + private static SimpleKey k(Class clazz, String key) { + return new SimpleKey(clazz, key); + } + + private static final class SimpleKey { + final Class c10nInterface; + final String key; + + private SimpleKey(Class c10nInterface, String key) { + this.c10nInterface = c10nInterface; + this.key = key; + } + + @SuppressWarnings("RedundantIfStatement")//rationale: generated code + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SimpleKey simpleKey = (SimpleKey) o; + + if (!c10nInterface.equals(simpleKey.c10nInterface)) return false; + if (!key.equals(simpleKey.key)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = c10nInterface.hashCode(); + result = 31 * result + key.hashCode(); + return result; + } + + @Override + public String toString() { + return "SimpleKey{" + + "c10nInterface=" + c10nInterface + + ", key='" + key + '\'' + + '}'; + } + } +} diff --git a/tools/src/test/java/c10n/tools/search/test1/Buttons.java b/tools/src/test/java/c10n/tools/search/test1/Buttons.java index 77d42c3..bb5a3ed 100755 --- a/tools/src/test/java/c10n/tools/search/test1/Buttons.java +++ b/tools/src/test/java/c10n/tools/search/test1/Buttons.java @@ -20,12 +20,15 @@ package c10n.tools.search.test1; import c10n.C10NDef; +import c10n.C10NKey; import c10n.C10NMessages; @C10NMessages +@C10NKey("buttons") public interface Buttons { - @C10NDef("OK") - String ok(); - @C10NDef("Cancel") - String cancel(); + @C10NDef("OK") + String ok(); + + @C10NDef("Cancel") + String cancel(); } diff --git a/tools/src/test/java/c10n/tools/search/test1/Window.java b/tools/src/test/java/c10n/tools/search/test1/Window.java index 5812f70..f9701b7 100755 --- a/tools/src/test/java/c10n/tools/search/test1/Window.java +++ b/tools/src/test/java/c10n/tools/search/test1/Window.java @@ -20,14 +20,16 @@ package c10n.tools.search.test1; import c10n.C10NDef; +import c10n.C10NKey; import c10n.C10NMessages; import c10n.tools.search.test1.labels.Labels; @C10NMessages +@C10NKey("window") public interface Window extends Buttons, Labels { - @C10NDef("Test01") - String title(); - - @C10NDef("rodion") - String author(); + @C10NDef("Test01") + String title(); + + @C10NDef("rodion") + String author(); } diff --git a/tools/src/test/java/c10n/tools/search/test1/labels/Labels.java b/tools/src/test/java/c10n/tools/search/test1/labels/Labels.java index 3b229e6..bff7c8f 100755 --- a/tools/src/test/java/c10n/tools/search/test1/labels/Labels.java +++ b/tools/src/test/java/c10n/tools/search/test1/labels/Labels.java @@ -22,5 +22,5 @@ import c10n.C10NMessages; @C10NMessages -public interface Labels extends Labels1, Labels2{ +public interface Labels extends Labels1, Labels2 { } diff --git a/tools/src/test/java/c10n/tools/search/test1/labels/Labels1.java b/tools/src/test/java/c10n/tools/search/test1/labels/Labels1.java index c57419c..ef0d343 100755 --- a/tools/src/test/java/c10n/tools/search/test1/labels/Labels1.java +++ b/tools/src/test/java/c10n/tools/search/test1/labels/Labels1.java @@ -20,12 +20,14 @@ package c10n.tools.search.test1.labels; import c10n.C10NDef; +import c10n.C10NKey; import c10n.C10NMessages; @C10NMessages +@C10NKey("labels") public interface Labels1 { - @C10NDef("label 1") - String label1(); - - String oops(); + @C10NDef("label 1") + String label1(); + + String oops(); } diff --git a/tools/src/test/java/c10n/tools/search/test1/labels/Labels2.java b/tools/src/test/java/c10n/tools/search/test1/labels/Labels2.java index a5a915e..c2710d6 100755 --- a/tools/src/test/java/c10n/tools/search/test1/labels/Labels2.java +++ b/tools/src/test/java/c10n/tools/search/test1/labels/Labels2.java @@ -20,10 +20,12 @@ package c10n.tools.search.test1.labels; import c10n.C10NDef; +import c10n.C10NKey; import c10n.C10NMessages; @C10NMessages +@C10NKey("labels") public interface Labels2 { - @C10NDef("label 2") - String label2(); + @C10NDef("label 2") + String label2(); }