org.eclipse.persistence.jpa.jpql.tools.model.ListChangeEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eclipselink Show documentation
Show all versions of eclipselink Show documentation
EclipseLink build based upon Git transaction 774c696
/*******************************************************************************
* Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation
*
******************************************************************************/
package org.eclipse.persistence.jpa.jpql.tools.model;
import java.util.List;
import org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject;
import org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject;
import org.eclipse.persistence.jpa.jpql.utility.iterable.ListIterable;
import org.eclipse.persistence.jpa.jpql.utility.iterable.SnapshotCloneListIterable;
/**
* The default implementation of {@link IListChangeListener} where the generics is the type of the
* items.
*
* @version 2.4
* @since 2.4
* @author Pascal Filion
*/
public class ListChangeEvent implements IListChangeEvent {
private int endIndex;
private EventType eventType;
private List items;
private List list;
private String listName;
/**
* The source where the modification occurred and that fired the event.
*/
private StateObject source;
private int startIndex;
/**
* Creates a new ListChangeEvent
.
*
* @param source The source where the modification occurred and that fired the event
*/
public ListChangeEvent(StateObject source,
List list,
EventType eventType,
String listName,
List items,
int startIndex,
int endIndex) {
super();
this.list = list;
this.items = items;
this.source = source;
this.endIndex = endIndex;
this.listName = listName;
this.eventType = eventType;
this.startIndex = startIndex;
}
/**
* {@inheritDoc}
*/
public int getEndIndex() {
return endIndex;
}
/**
* {@inheritDoc}
*/
public EventType getEventType() {
return eventType;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public List getList() {
return (List) list;
}
/**
* {@inheritDoc}
*/
public String getListName() {
return listName;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public > S getSource() {
return (S) source;
}
/**
* {@inheritDoc}
*/
public int getStartIndex() {
return startIndex;
}
/**
* {@inheritDoc}
*/
public ListIterable items() {
return new SnapshotCloneListIterable(items);
}
/**
* {@inheritDoc}
*/
public int itemsSize() {
return items.size();
}
}