diff --git a/pom.xml b/pom.xml index 869b3e504b..dfb32f32ae 100644 --- a/pom.xml +++ b/pom.xml @@ -64,6 +64,13 @@ codemodel-project 2.6 + + junit + junit + 4.10 + test + + \ No newline at end of file diff --git a/src/main/java/com/speedment/util/$.java b/src/main/java/com/speedment/util/$.java new file mode 100644 index 0000000000..6c53558434 --- /dev/null +++ b/src/main/java/com/speedment/util/$.java @@ -0,0 +1,62 @@ +/** + * + * Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved. + * + * 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. + */ +package com.speedment.util; + +/** + * + * @author Duncan + */ +public class $ implements CharSequence { + + private final StringBuilder str; + + public $() { + this(""); + } + + public $(CharSequence... objects) { + str = new StringBuilder(); + $(objects); + } + + public final $ $(CharSequence... objects) { + for (CharSequence object : objects) { + str.append(object); + } + return this; + } + + @Override + public int length() { + return str.length(); + } + + @Override + public char charAt(int index) { + return str.charAt(index); + } + + @Override + public CharSequence subSequence(int start, int end) { + return str.subSequence(start, end); + } + + @Override + public String toString() { + return str.toString(); + } +} \ No newline at end of file diff --git a/src/test/java/com/speedment/util/TestDollar.java b/src/test/java/com/speedment/util/TestDollar.java new file mode 100644 index 0000000000..b56329884f --- /dev/null +++ b/src/test/java/com/speedment/util/TestDollar.java @@ -0,0 +1,59 @@ +/** + * + * Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved. + * + * 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. + */ +package com.speedment.util; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +/** + * + * @author Duncan + */ +public class TestDollar { + + private $ instance; + + public TestDollar() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + instance = new $(); + } + + @After + public void tearDown() { + } + + @Test + public void testConcatenation() { + instance.$("qwerty").$("asdfg", "zxcvb"); + assertEquals("qwertyasdfgzxcvb", instance.toString()); + } +}