Skip to content

Instantly share code, notes, and snippets.

@mo-gr
Created July 19, 2012 10:49
Show Gist options
  • Save mo-gr/3142986 to your computer and use it in GitHub Desktop.
Save mo-gr/3142986 to your computer and use it in GitHub Desktop.
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.fest.assertions.Assertions.assertThat;
public class Solution {
@Test
public void test() {
final Foo foo = new Foo();
foo.setStrings(Arrays.asList("a", "b", "c"));
foo.setStrings(foo.getStrings());
assertThat(foo.getStrings()).contains("a", "b", "c");
}
static class Foo {
private final List<String > blas = new ArrayList<String>();
public List<String> getStrings() { return Collections.unmodifiableList(new ArrayList<String>(blas)); }
public void setStrings(List<String> blas) {
if (blas != null) {
this.blas.clear();
this.blas.addAll(blas);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment