Tabnine Logo
FunctionList
Code IndexAdd Tabnine to your IDE (free)

How to use
FunctionList
in
ca.odell.glazedlists

Best Java code snippets using ca.odell.glazedlists.FunctionList (Showing top 20 results out of 315)

origin: net.java.dev.glazedlists/glazedlists_java15

/**
 * Adapts the given <code>source</code> to the PieDataset interface. The
 * given <code>keyFunction</code> is then applied to each element of the
 * <code>source</code> to produce the unique key for the element and the
 * given <code>valueFunction</code> is applied to produce the value for an
 * element.
 *
 * <p>This constructor should be used when the elements in
 * <code>source</code> do not need to be grouped together in order to
 * represent pie data.
 *
 * @param source the {@link EventList} containing the data to chart
 * @param keyFunction produces the keys of the source elements in the pie chart
 * @param valueFunction produces the values of the source elements in the pie chart
 */
public EventListPieDataset(EventList<E> source, FunctionList.Function<E, Comparable<K>> keyFunction, FunctionList.Function<E, Number> valueFunction) {
  this.groupingList = null;
  this.sourceList = source;
  this.keyList = new FunctionList(source, keyFunction);
  this.valueList = new FunctionList(source, valueFunction);
  source.addListEventListener(this.datasetEventListener);
}
origin: com.haulmont.thirdparty/glazedlists

/** {@inheritDoc} */
public void dispose() {
  valueList.removeListEventListener(this);
  valueList.dispose();
  groupingList.dispose();
  keySet = null;
  entrySet = null;
  keyList.clear();
  delegate.clear();
}
origin: net.java.dev.glazedlists/glazedlists_java16

/**
 * Returns the key of the value at the given <code>index</code>.
 *
 * @param index the item index (zero-based)
 * @return the key
 *
 * @throws IndexOutOfBoundsException if <code>index</code> is out of bounds
 */
@Override
public Comparable getKey(int index) {
  return this.keyList.get(index);
}
origin: net.java.dev.glazedlists/glazedlists_java15

/** {@inheritDoc} */
@Override
public E set(int index, E value) {
  final E updated = get(index);
  source.set(index, reverse(value));
  return updated;
}
origin: net.java.dev.glazedlists/glazedlists_java16

this.valueList = new FunctionList<List<V>, List<V>>(this.groupingList, new ValueListFunction());
this.valueList.addListEventListener(this);
for (Iterator<List<V>> i = this.valueList.iterator(); i.hasNext();) {
  final List<V> value = i.next();
  final K key = key(value);
origin: net.java.dev.glazedlists/glazedlists_java15

/**
 * Construct a {@link FunctionList} which stores the result of transforming
 * each source element using the given forward {@link Function}. If the
 * reverse {@link Function} is not null, {@link #add(Object)},
 * {@link #add(int, Object)} and {@link #set(int, Object)} will execute
 * as expected.
 *
 * <p> Note: an {@link AdvancedFunction} can be specified for the forward
 * {@link Function} which allows the implementor a chance to examine the
 * prior value that was mapped to a source element when it must be remapped
 * due to a modification (from a call to {@link List#set}).
 *
 * @param source the EventList to decorate with a function transformation
 * @param forward the function to execute on each source element
 * @param reverse the function to map elements of FunctionList back to
 *      element values in the source list
 */
public FunctionList(EventList<S> source, Function<S,E> forward, Function<E,S> reverse) {
  super(source);
  updateForwardFunction(forward);
  setReverseFunction(reverse);
  // save a reference to the source elements
  this.sourceElements = new ArrayList<S>(source);
  // map all of the elements within source
  this.mappedElements = new ArrayList<E>(source.size());
  for (int i = 0, n = source.size(); i < n; i++) {
    this.mappedElements.add(forward(source.get(i)));
  }
  source.addListEventListener(this);
}
origin: org.marketcetera/core

  @Override
  public void dispose() {
    summarized3.dispose();
    grouped3.dispose();
    summarized2.dispose();
    grouped2.dispose();
    summarized1.dispose();
    grouped1.dispose();
  }
};
origin: net.java.dev.glazedlists/glazedlists_java15

/**
 * Changes the {@link Function} that evaluates source elements to produce
 * mapped elements. Calling this method with a different
 * <code>forward</code> Function will cause all elements in this
 * FunctionList to be reevaluated.
 *
 * <p>Callers of this method typically also want to update the reverse
 * function using {@link #setReverseFunction} if one exists.
 */
public void setForwardFunction(Function<S,E> forward) {
  updateForwardFunction(forward);
  updates.beginEvent(true);
  // remap all of the elements within source
  for (int i = 0, n = source.size(); i < n; i++) {
    final E oldValue = this.mappedElements.set(i, forward(source.get(i)));
    updates.elementUpdated(i, oldValue);
  }
  updates.commitEvent();
}
origin: com.haulmont.thirdparty/glazedlists

final E newValueTransformed = forward(newValue);
sourceElements.add(changeIndex, newValue);
mappedElements.add(changeIndex, newValueTransformed);
final E oldValueTransformed = get(changeIndex);
final S newValue = source.get(changeIndex);
final E newValueTransformed = forward(oldValueTransformed, newValue);
sourceElements.set(changeIndex, newValue);
mappedElements.set(changeIndex, newValueTransformed);
origin: com.haulmont.thirdparty/glazedlists

/**
 * Returns the index for a given key.
 *
 * @param key the key
 * @return the index, or <code>-1</code> if the key is unrecognised
 */
public int getIndex(Comparable key) {
  return this.keyList.indexOf(key);
}
origin: com.haulmont.thirdparty/glazedlists

/** {@inheritDoc} */
@Override
public void add(int index, E value) {
  source.add(index, reverse(value));
}
origin: net.java.dev.glazedlists/glazedlists_java15

this.valueList = new FunctionList<List<V>, List<V>>(this.groupingList, new ValueListFunction());
this.valueList.addListEventListener(this);
for (Iterator<List<V>> i = this.valueList.iterator(); i.hasNext();) {
  final List<V> value = i.next();
  final K key = key(value);
origin: com.haulmont.thirdparty/glazedlists

/**
 * Construct a {@link FunctionList} which stores the result of transforming
 * each source element using the given forward {@link Function}. If the
 * reverse {@link Function} is not null, {@link #add(Object)},
 * {@link #add(int, Object)} and {@link #set(int, Object)} will execute
 * as expected.
 *
 * <p> Note: an {@link AdvancedFunction} can be specified for the forward
 * {@link Function} which allows the implementor a chance to examine the
 * prior value that was mapped to a source element when it must be remapped
 * due to a modification (from a call to {@link List#set}).
 *
 * @param source the EventList to decorate with a function transformation
 * @param forward the function to execute on each source element
 * @param reverse the function to map elements of FunctionList back to
 *      element values in the source list
 */
public FunctionList(EventList<S> source, Function<S,E> forward, Function<E,S> reverse) {
  super(source);
  updateForwardFunction(forward);
  setReverseFunction(reverse);
  // save a reference to the source elements
  this.sourceElements = new ArrayList<S>(source);
  // map all of the elements within source
  this.mappedElements = new ArrayList<E>(source.size());
  for (int i = 0, n = source.size(); i < n; i++) {
    this.mappedElements.add(forward(source.get(i)));
  }
  source.addListEventListener(this);
}
origin: net.java.dev.glazedlists/glazedlists_java15

  public void dispose() {
    if(sortedList != null) {
      sortedList.dispose();
    }
    sourceNodes.dispose();
  }
}
origin: net.java.dev.glazedlists/glazedlists_java16

/** {@inheritDoc} */
@Override
public E set(int index, E value) {
  final E updated = get(index);
  source.set(index, reverse(value));
  return updated;
}
origin: com.haulmont.thirdparty/glazedlists

/**
 * Changes the {@link Function} that evaluates source elements to produce
 * mapped elements. Calling this method with a different
 * <code>forward</code> Function will cause all elements in this
 * FunctionList to be reevaluated.
 *
 * <p>Callers of this method typically also want to update the reverse
 * function using {@link #setReverseFunction} if one exists.
 */
public void setForwardFunction(Function<S,E> forward) {
  updateForwardFunction(forward);
  updates.beginEvent(true);
  // remap all of the elements within source
  for (int i = 0, n = source.size(); i < n; i++) {
    final E oldValue = this.mappedElements.set(i, forward(source.get(i)));
    updates.elementUpdated(i, oldValue);
  }
  updates.commitEvent();
}
origin: net.java.dev.glazedlists/glazedlists_java15

final E newValueTransformed = forward(newValue);
sourceElements.add(changeIndex, newValue);
mappedElements.add(changeIndex, newValueTransformed);
final E oldValueTransformed = get(changeIndex);
final S newValue = source.get(changeIndex);
final E newValueTransformed = forward(oldValueTransformed, newValue);
sourceElements.set(changeIndex, newValue);
mappedElements.set(changeIndex, newValueTransformed);
origin: net.java.dev.glazedlists/glazedlists_java15

/**
 * Returns the index for a given key.
 *
 * @param key the key
 * @return the index, or <code>-1</code> if the key is unrecognised
 */
public int getIndex(Comparable key) {
  return this.keyList.indexOf(key);
}
origin: net.java.dev.glazedlists/glazedlists_java16

/** {@inheritDoc} */
@Override
public void add(int index, E value) {
  source.add(index, reverse(value));
}
origin: net.java.dev.glazedlists/glazedlists_java16

/**
 * Adapts the given <code>source</code> to the PieDataset interface. The
 * given <code>keyFunction</code> is then applied to each element of the
 * <code>source</code> to produce the unique key for the element and the
 * given <code>valueFunction</code> is applied to produce the value for an
 * element.
 *
 * <p>This constructor should be used when the elements in
 * <code>source</code> do not need to be grouped together in order to
 * represent pie data.
 *
 * @param source the {@link EventList} containing the data to chart
 * @param keyFunction produces the keys of the source elements in the pie chart
 * @param valueFunction produces the values of the source elements in the pie chart
 */
public EventListPieDataset(EventList<E> source, FunctionList.Function<E, Comparable<K>> keyFunction, FunctionList.Function<E, Number> valueFunction) {
  this.groupingList = null;
  this.sourceList = source;
  this.keyList = new FunctionList(source, keyFunction);
  this.valueList = new FunctionList(source, valueFunction);
  source.addListEventListener(this.datasetEventListener);
}
ca.odell.glazedlistsFunctionList

Javadoc

This List is meant to simplify the task of transforming each element of a source list to an element stored at the same index in this FunctionList. The logic of precisely how to transform the source elements is contained within a Function that must be supplied at the time of construction but can be changed afterward using #setForwardFunction. This Function is called the forward function because it creates elements in this FunctionList from elements that have been added or mutated within the source list. The forward function may be an implementation of either Function or AdvancedFunction.

An optional reverse Function which is capable of mapping the elements of this FunctionList back to the corresponding source element may be supplied in order to use the following mutating methods:

  • #add(Object)
  • #add(int,Object)
  • #set(int,Object)
If the reverse Function is not supplied then callers of those methods will receive an IllegalStateException explaining that those operations are not available without the reverse Function.

If specified, the reverse Function should do its best to maintain the invariant:

o.equals(reverseFunction.evaluate(forwardFunction.evaluate(o))) for any o that is non-null.

Note: if two source elements share the same identity (i.e. source.get(i) == source.get(j) when i != j), it is up to author of the Function to decide if and how to preserve the relationship of their identities after their transformation.

Warning: This class is thread ready but not thread safe. See EventList for an example of thread safe code.

EventList Overview
Writable:yes
Concurrency:thread ready, not thread safe
Performance:reads: O(1), writes O(1) amortized
Memory:
Unit Tests:FunctionList
Issues: 282

Most used methods

  • <init>
    Construct a FunctionList which stores the result of transforming each source element using the given
  • dispose
  • addListEventListener
  • forward
    A convenience method to remap a source element to a FunctionListelement using the forward Function.
  • get
  • indexOf
  • iterator
  • removeListEventListener
  • reverse
    A convenience method to map a FunctionList element to a source element using the reverse Function.
  • setReverseFunction
    Changes the Function that evaluates FunctionList elements to produce the original source element wit
  • size
  • updateForwardFunction
    A convenience method to run a null check on the givenforward Function and to wrap it in a delegating
  • size,
  • updateForwardFunction

Popular in Java

  • Running tasks concurrently on multiple threads
  • setScale (BigDecimal)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setContentView (Activity)
  • Menu (java.awt)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now