Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |