[OPENJPA-2751] imports, @Overrides and @Deprecated are organized, redundant type arguments and unnecessary casts are removed

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1842686 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Maxim Solodovnik 2018-10-03 08:11:59 +00:00
parent f2fc98031e
commit e25438a174
3476 changed files with 29036 additions and 10094 deletions

View File

@ -18,18 +18,19 @@
*/
package org.apache.openjpa.example.gallery.constraint;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.apache.openjpa.example.gallery.ImageType.GIF;
import static org.apache.openjpa.example.gallery.ImageType.JPEG;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import javax.validation.Constraint;
import javax.validation.Payload;
import org.apache.openjpa.example.gallery.ImageType;
import static org.apache.openjpa.example.gallery.ImageType.GIF;
import static org.apache.openjpa.example.gallery.ImageType.JPEG;
/**
* Type-level annotation used to specify an image constraint. Uses

View File

@ -18,19 +18,20 @@
*/
package org.apache.openjpa.example.gallery.constraint;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.apache.openjpa.example.gallery.ImageType.GIF;
import static org.apache.openjpa.example.gallery.ImageType.JPEG;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import javax.validation.Constraint;
import javax.validation.Payload;
import org.apache.openjpa.example.gallery.ImageType;
import static org.apache.openjpa.example.gallery.ImageType.GIF;
import static org.apache.openjpa.example.gallery.ImageType.JPEG;
/**
* Attribute-level annotation used to specify an image content constraint. Uses

View File

@ -37,6 +37,7 @@ public class ImageContentValidator implements ConstraintValidator<ImageContent,
* types it should support.
* @param constraint the constraint definition
*/
@Override
public void initialize(ImageContent constraint) {
allowedTypes = Arrays.asList(constraint.value());
}
@ -44,6 +45,7 @@ public class ImageContentValidator implements ConstraintValidator<ImageContent,
/**
* Validate a specified value.
*/
@Override
public boolean isValid(byte[] value, ConstraintValidatorContext context) {
if (value == null) {
return false;

View File

@ -38,6 +38,7 @@ public class ImageValidator implements ConstraintValidator<ImageConstraint, Imag
* types it should support.
* @param constraint the constraint definition
*/
@Override
public void initialize(ImageConstraint constraint) {
allowedTypes = Arrays.asList(constraint.value());
}
@ -45,6 +46,7 @@ public class ImageValidator implements ConstraintValidator<ImageConstraint, Imag
/**
* Validate a specified value.
*/
@Override
public boolean isValid(Image value, ConstraintValidatorContext context) {
// JSR-303 best practice. Promotes the use of @NotNull to perform
// null checking.

View File

@ -23,8 +23,8 @@ import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
/**

View File

@ -46,8 +46,8 @@ import javax.servlet.http.HttpServletResponse;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class SimpleApp extends HttpServlet {
private static final long serialVersionUID = 1L;
EntityManagerFactory _emf;
private static String UNIT_NAME = "jestdemo";

View File

@ -23,6 +23,7 @@ import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
/**
* Displays color codes of each attribute type.
@ -30,8 +31,8 @@ import javax.swing.JPanel;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class AttributeLegendView extends JPanel {
private static final long serialVersionUID = 1L;
public AttributeLegendView() {
super(true);
@ -51,7 +52,7 @@ public class AttributeLegendView extends JPanel {
for (int i = 0; i < width; i++)
for (int j = 0; j < height; j++)
bimage.setRGB(i, j, c.getRGB());
JLabel label = new JLabel(text, new ImageIcon(bimage), JLabel.LEADING);
JLabel label = new JLabel(text, new ImageIcon(bimage), SwingConstants.LEADING);
return label;
}

View File

@ -24,8 +24,8 @@ import javax.swing.JLabel;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class AttributeView extends JLabel {
private static final long serialVersionUID = 1L;
private final Attribute<?,?> _attr;
public AttributeView(Attribute<?,?> attr) {

View File

@ -28,14 +28,14 @@ import javax.swing.JTextPane;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class ConfigurationViewer extends JTextPane {
private static final long serialVersionUID = 1L;
private static final char SPACE = ' ';
public ConfigurationViewer(String title, Map<String, Object> config) {
super();
setBorder(BorderFactory.createTitledBorder(title));
TreeSet<String> sortedKeys = new TreeSet<String>(config.keySet());
TreeSet<String> sortedKeys = new TreeSet<>(config.keySet());
int L = getMaxLength(sortedKeys);
for (String key : sortedKeys) {
setCaretPosition(getDocument().getLength());

View File

@ -39,8 +39,8 @@ import javax.swing.table.TableModel;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class EntityDataModel<T> extends AbstractTableModel implements TableModel, Iterable<T> {
private static final long serialVersionUID = 1L;
/**
* Constant designates to include non-relation fields.
*/
@ -84,10 +84,10 @@ public class EntityDataModel<T> extends AbstractTableModel implements TableModel
this.data = data;
EntityType<T> entityType = meta.entity(cls);
columnNames = new ArrayList<String>();
columnClasses = new ArrayList<Class<?>>();
attributes = new ArrayList<Attribute<? super T,?>>();
methods = new ArrayList<Method>();
columnNames = new ArrayList<>();
columnClasses = new ArrayList<>();
attributes = new ArrayList<>();
methods = new ArrayList<>();
showsRowCount = (styleBits & ROW_COUNT) != 0;
showsBasicAttr = (styleBits & BASIC_ATTR) != 0;

View File

@ -23,9 +23,9 @@ import javax.persistence.PersistenceUnitUtil;
import javax.persistence.metamodel.Attribute;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
@ -48,8 +48,8 @@ import org.apache.openjpa.enhance.StateManager;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class EntityTable<T> extends JTable {
private static final long serialVersionUID = 1L;
private InstanceCellRenderer instanceCellRenderer;
private CollectionCellRenderer collectionCellRenderer;
@ -59,7 +59,7 @@ public class EntityTable<T> extends JTable {
collectionCellRenderer = new CollectionCellRenderer();
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setModel(new EntityDataModel<T>(cls, data, unit.getMetamodel(), styleBits));
setModel(new EntityDataModel<>(cls, data, unit.getMetamodel(), styleBits));
getModel().addTableModelListener(this);
initColumnSizes();
setFillsViewportHeight(true);
@ -74,6 +74,7 @@ public class EntityTable<T> extends JTable {
* Gets the special renderer for single- and multi-valued association.
* Otherwise uses the super classes' renderer defined by the field type.
*/
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
Attribute<?,?> attr = ((EntityDataModel)getModel()).getAttribute(column);
TableCellRenderer renderer = null;
@ -87,12 +88,13 @@ public class EntityTable<T> extends JTable {
renderer = super.getCellRenderer(row, column);
}
if (renderer instanceof DefaultTableCellRenderer) {
((DefaultTableCellRenderer)renderer).setHorizontalAlignment(JLabel.CENTER);
((DefaultTableCellRenderer)renderer).setHorizontalAlignment(SwingConstants.CENTER);
}
return renderer;
}
@Override
public TableCellEditor getCellEditor(int row, int column) {
Attribute<?,?> attr = ((EntityDataModel)getModel()).getAttribute(column);
if (attr == null)
@ -145,6 +147,8 @@ public class EntityTable<T> extends JTable {
*
*/
public class InstanceCellRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = 1L;
private final PersistenceUnitUtil util;
public InstanceCellRenderer(PersistenceUnitUtil util) {
@ -171,6 +175,7 @@ public class EntityTable<T> extends JTable {
return id == null ? "null" : id.toString();
}
@Override
public void setValue(Object instance) {
setForeground(Color.BLUE);
setText(renderAsString(instance));
@ -186,6 +191,8 @@ public class EntityTable<T> extends JTable {
*
*/
public class CollectionCellRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = 1L;
public CollectionCellRenderer() {
setPreferredSize(new Dimension(10,20));
}

View File

@ -28,6 +28,7 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
@ -42,18 +43,18 @@ import jpa.tools.swing.EntityTable.InstanceCellRenderer;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class EntityTableView<T> extends JPanel implements ListSelectionListener {
private static final long serialVersionUID = 1L;
private EntityTable<T> _table;
private JTextArea _details;
public EntityTableView(Class<T> cls, int styleBits, EntityManagerFactory unit) {
this(cls, (List<T>)Collections.EMPTY_LIST, styleBits, unit);
this(cls, Collections.emptyList(), styleBits, unit);
}
public EntityTableView(Class<T> cls, List<T> data, int styleBits, EntityManagerFactory unit) {
super(true);
_table = new EntityTable<T>(cls, data, styleBits, unit);
_table = new EntityTable<>(cls, data, styleBits, unit);
_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
if ((styleBits & EntityDataModel.PLURAL_ATTR) != 0) {
@ -68,8 +69,8 @@ public class EntityTableView<T> extends JPanel implements ListSelectionListener
setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
add(new JScrollPane(_table,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS));
if (_details != null)
add(_details);
}

View File

@ -31,8 +31,8 @@ import javax.swing.JPanel;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class EntityTypeView<T> extends JPanel {
private static final long serialVersionUID = 1L;
final EntityType<T> type;
final int hgap = 4;
final int vgap = 4;

View File

@ -32,6 +32,8 @@ import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.WindowConstants;
/**
* A dialog to display runtime error.
@ -39,8 +41,8 @@ import javax.swing.JTextPane;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class ErrorDialog extends JDialog {
private static final long serialVersionUID = 1L;
private static List<String> filters = Arrays.asList(
"java.awt.",
"javax.swing.",
@ -87,7 +89,7 @@ public class ErrorDialog extends JDialog {
setModal(true);
if (icon != null && icon instanceof ImageIcon)
setIconImage(((ImageIcon)icon).getImage());
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
_error = t;
_message = createErrorMessage(_error);
_main = createContent();
@ -106,6 +108,7 @@ public class ErrorDialog extends JDialog {
JComponent createContent() {
final JButton showDetails = new JButton("Show Details >>");
showDetails.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (_showingDetails) {
_main.remove(_details);
@ -133,6 +136,7 @@ public class ErrorDialog extends JDialog {
final JCheckBox filter = new JCheckBox("Filter stack traces");
filter.setSelected(_isFiltering);
filter.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
_isFiltering = filter.isSelected();
StringBuilder buffer = new StringBuilder();
@ -178,8 +182,8 @@ public class ErrorDialog extends JDialog {
_stacktrace = new JTextPane();
_stacktrace.setEditable(false);
JScrollPane pane = new JScrollPane(_stacktrace,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
return pane;
}

View File

@ -36,7 +36,7 @@ public class FileScanner {
* Scans the given
*/
public List<File> scan(File dir) {
List<File> bag = new ArrayList<File>();
List<File> bag = new ArrayList<>();
scan(dir, bag);
return bag;
}

View File

@ -79,6 +79,7 @@ public class Finder {
private void scan(File dir, String cls) throws IOException {
File[] classes = dir.listFiles(new FileFilter() {
@Override
public boolean accept(File path) {
return path.getName().endsWith(CLASS_SUFFIX);
}
@ -91,6 +92,7 @@ public class Finder {
}
File[] jars = dir.listFiles(new FileFilter() {
@Override
public boolean accept(File path) {
return path.getName().endsWith(JAR_SUFFIX);
}
@ -102,6 +104,7 @@ public class Finder {
}
File[] dirs = dir.listFiles(new FileFilter() {
@Override
public boolean accept(File path) {
return path.isDirectory();
}

View File

@ -32,7 +32,7 @@ public class GraphicOutputStream extends OutputStream {
ScrollingTextPane _sink;
private char[] buffer = new char[1024];
private int count;
private Map<String, AttributeSet> _styles = new HashMap<String, AttributeSet>();
private Map<String, AttributeSet> _styles = new HashMap<>();
private static AttributeSet _defaultStyle = StyleContext.getDefaultStyleContext()
.getStyle(StyleContext.DEFAULT_STYLE);

View File

@ -39,21 +39,24 @@ import java.util.Set;
* @param <V>
*/
public class IndexedMap<K,V> implements Map<K, V> {
private final List<K> _keys = new ArrayList<K>();
private final List<V> _values = new ArrayList<V>();
private final Set<K> _nulls = new HashSet<K>();
private final List<K> _keys = new ArrayList<>();
private final List<V> _values = new ArrayList<>();
private final Set<K> _nulls = new HashSet<>();
@Override
public void clear() {
_keys.clear();
_values.clear();
}
@Override
public boolean containsKey(Object key) {
return _keys.contains(key) && !_nulls.contains(key);
}
@Override
public boolean containsValue(Object value) {
return _values.contains(value);
}
@ -61,26 +64,31 @@ public class IndexedMap<K,V> implements Map<K, V> {
/**
* Not supported.
*/
@Override
public Set<java.util.Map.Entry<K, V>> entrySet() {
throw new UnsupportedOperationException();
}
@Override
public V get(Object key) {
int i = indexOf(key);
return i == -1 ? null : _values.get(i);
}
@Override
public boolean isEmpty() {
return (_keys.size() - _nulls.size()) == 0;
}
@Override
public Set<K> keySet() {
Set<K> result = new HashSet<K>(_keys);
Set<K> result = new HashSet<>(_keys);
result.removeAll(_nulls);
return result;
}
@Override
public V put(K key, V value) {
int i = _keys.indexOf(key);
if (i == -1) {
@ -93,12 +101,14 @@ public class IndexedMap<K,V> implements Map<K, V> {
}
}
@Override
public void putAll(Map<? extends K, ? extends V> m) {
for (K k : m.keySet()) {
this.put(k, m.get(k));
}
}
@Override
@SuppressWarnings("unchecked")
public V remove(Object key) {
V v = get(key);
@ -106,12 +116,14 @@ public class IndexedMap<K,V> implements Map<K, V> {
return v;
}
@Override
public int size() {
return _keys.size() - _nulls.size();
}
@Override
public Collection<V> values() {
Collection<V> result = new ArrayList<V>();
Collection<V> result = new ArrayList<>();
for (int i = 0; i < _values.size(); i++) {
if (!_nulls.contains(_keys.get(i)))
result.add(_values.get(i));

View File

@ -19,8 +19,8 @@ import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.EntityType;
import javax.swing.table.AbstractTableModel;
@SuppressWarnings("serial")
public class InstanceDataModel<T> extends AbstractTableModel {
private static final long serialVersionUID = 1L;
List<Attribute<? super T, ?>> attributes;
private T _instance;

View File

@ -16,10 +16,11 @@ package jpa.tools.swing;
import javax.persistence.metamodel.EntityType;
import javax.swing.JTable;
@SuppressWarnings("serial")
public class InstanceView<T> extends JTable {
private static final long serialVersionUID = 1L;
public InstanceView(EntityType<T> type, T instance) {
super(new InstanceDataModel<T>(type, instance));
super(new InstanceDataModel<>(type, instance));
setShowHorizontalLines(false);
setShowVerticalLines(false);
}

View File

@ -88,7 +88,7 @@ public class MetamodelHelper {
public static <T> List<Attribute<? super T,?>> getAttributes(EntityType<T> type) {
List<Attribute<? super T,?>> list = new ArrayList<Attribute<? super T,?>>(type.getAttributes());
List<Attribute<? super T,?>> list = new ArrayList<>(type.getAttributes());
Collections.sort(list, new AttributeComparator());
return list;
}
@ -110,7 +110,7 @@ public class MetamodelHelper {
public static <T> Set<SingularAttribute<? super T, ?>> getIdAttributes(EntityType<T> type) {
Set<SingularAttribute<? super T,?>> attrs = type.getSingularAttributes();
Set<SingularAttribute<? super T,?>> idAttrs = new HashSet<SingularAttribute<? super T,?>>();
Set<SingularAttribute<? super T,?>> idAttrs = new HashSet<>();
for (SingularAttribute<? super T,?> attr : attrs) {
if (attr.isId()) {
idAttrs.add(attr);
@ -192,7 +192,7 @@ public class MetamodelHelper {
default: return 5;
}
}
private static Map<Attribute<?,?>, Method> members = new HashMap<Attribute<?,?>, Method>();
private static Map<Attribute<?,?>, Method> members = new HashMap<>();
private static Object[] EMPTY_ARGS = null;
private static Class<?>[] EMPTY_CLASSES = null;
/**

View File

@ -43,9 +43,8 @@ import javax.swing.JPanel;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class MetamodelView extends JPanel implements Maze {
private static final long serialVersionUID = 1L;
private static final int GRID = 8;
int hgap = 40;
int vgap = 40;
@ -63,7 +62,7 @@ public class MetamodelView extends JPanel implements Maze {
layout.setVgap(80);
// getInsets(new Insets(100,100,100,100));
Set<EntityType<?>> types = model.getEntities();
List<EntityType<?>> sorted = new ArrayList<EntityType<?>>(types);
List<EntityType<?>> sorted = new ArrayList<>(types);
Collections.sort(sorted, new MetamodelHelper.EntityComparator());
for (EntityType type : sorted) {
EntityTypeView view = new EntityTypeView(type);

View File

@ -58,8 +58,8 @@ public class PathFinder {
Node source = new Node(null, x1, y1);
Node target = new Node(null, x2, y2);
int maxCost = distance(source, target)*2;
LinkedList<Node> openList = new LinkedList<Node>();
List<Node> closedList = new ArrayList<Node>();
LinkedList<Node> openList = new LinkedList<>();
List<Node> closedList = new ArrayList<>();
openList.add(source);
do {
Node current = openList.remove(0);
@ -119,7 +119,7 @@ public class PathFinder {
}
List<Point> traceBackPath(Node target) {
LinkedList<Point> path = new LinkedList<Point>();
LinkedList<Point> path = new LinkedList<>();
path.add(new Point(target.x, target.y));
Node next = target.parent;
while (next != null) {
@ -132,7 +132,7 @@ public class PathFinder {
List<Point> straighten(List<Point> path) {
if (path.size() < 3)
return path;
List<Point> mids = new ArrayList<Point>();
List<Point> mids = new ArrayList<>();
Point prev = path.get(0);
Point mid = path.get(1);
for (int i = 2; i < path.size(); i++) {
@ -158,6 +158,7 @@ public class PathFinder {
this.y = y;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o instanceof Node) {
@ -173,6 +174,7 @@ public class PathFinder {
return f > o.f ? 1 : -1;
}
@Override
public String toString() {
return "(" + x + "," + y + ":" + g + ")";
}

View File

@ -40,9 +40,9 @@ import openbook.client.Images;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class PowerPointViewer extends JPanel {
private List<WeakReference<ImageIcon>> _slides = new ArrayList<WeakReference<ImageIcon>>();
private static final long serialVersionUID = 1L;
private List<WeakReference<ImageIcon>> _slides = new ArrayList<>();
private int _total; // Total number of slides in the deck.
private String _dir;
private List<URL> _slideURLs;
@ -89,6 +89,7 @@ public class PowerPointViewer extends JPanel {
_prev = new RoundButton(Images.BACK);
buttons.add(_prev);
_prev.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
prevPage();
}
@ -101,6 +102,7 @@ public class PowerPointViewer extends JPanel {
buttons.add(gotoLabel);
buttons.add(_goto);
_goto.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
Integer page = (Integer)_goto.getValue();
showPage(page-1);
@ -112,6 +114,7 @@ public class PowerPointViewer extends JPanel {
buttons.add(_navButtons[i]);
_navButtons[i].putClientProperty(SLIDE_INDEX, i+1);
_navButtons[i].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JButton button = (JButton)e.getSource();
int index = (Integer)button.getClientProperty(SLIDE_INDEX);
@ -123,6 +126,7 @@ public class PowerPointViewer extends JPanel {
buttons.add(Box.createHorizontalGlue());
buttons.add(_next);
_next.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nextPage();
}
@ -198,12 +202,12 @@ public class PowerPointViewer extends JPanel {
ImageIcon loadSlide(int index) {
URL imgURL = _slideURLs.get(index);
ImageIcon icon = new ImageIcon(imgURL);
_slides.add(index, new WeakReference<ImageIcon>(icon));
_slides.add(index, new WeakReference<>(icon));
return icon;
}
List<URL> validateSlides(String dir, List<String> slides) {
List<URL> valid = new ArrayList<URL>();
List<URL> valid = new ArrayList<>();
for (String slide : slides) {
URL url = findResource(dir + slide);
if (url != null) {

View File

@ -15,7 +15,6 @@ package jpa.tools.swing;
import javax.swing.JTable;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
@ -25,8 +24,8 @@ import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class PreparedQueryViewer extends JTable {
private static final long serialVersionUID = 1L;
public PreparedQueryViewer(OpenJPAEntityManagerFactory emf) {
super(new QueryStatisticsModel(((OpenJPAEntityManagerFactorySPI)emf).getConfiguration()

View File

@ -21,10 +21,10 @@ import javax.swing.table.AbstractTableModel;
import org.apache.openjpa.kernel.QueryStatistics;
@SuppressWarnings("serial")
class QueryStatisticsModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
QueryStatistics<String> _stats;
private List<String> _keys = new ArrayList<String>();
private List<String> _keys = new ArrayList<>();
QueryStatisticsModel(QueryStatistics<String> stats) {
_stats = stats;
@ -65,7 +65,7 @@ class QueryStatisticsModel extends AbstractTableModel {
void sortKeys(QueryStatistics<String> stats) {
if (_stats.keys().size() != _keys.size()) {
_keys = new ArrayList<String>(_stats.keys());
_keys = new ArrayList<>(_stats.keys());
if (_keys.size() > 1) {
Collections.sort(_keys);
}

View File

@ -34,8 +34,8 @@ import javax.swing.JButton;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class RoundButton extends JButton {
private static final long serialVersionUID = 1L;
protected Shape shape, base;
public RoundButton() {

View File

@ -32,8 +32,8 @@ import javax.swing.text.Document;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class ScrollingTextPane extends JTextPane {
private static final long serialVersionUID = 1L;
public void appendText(String text) {
if (text == null)

View File

@ -28,6 +28,7 @@ import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
/**
@ -39,12 +40,12 @@ import javax.swing.JScrollPane;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class SourceCodeViewer extends JPanel {
private static final long serialVersionUID = 1L;
private final JEditorPane _editor;
private final JComboBox _bookmarks;
private IndexedMap<String, URI> _anchors = new IndexedMap<String, URI>();
private LinkedList<String> _visited = new LinkedList<String>();
private IndexedMap<String, URI> _anchors = new IndexedMap<>();
private LinkedList<String> _visited = new LinkedList<>();
/**
* Create a Source Code Browser.
@ -62,6 +63,7 @@ public class SourceCodeViewer extends JPanel {
_bookmarks.setEditable(false);
_bookmarks.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
showAnchor((String)_bookmarks.getSelectedItem());
}
@ -75,8 +77,8 @@ public class SourceCodeViewer extends JPanel {
add(new JScrollPane(_editor,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS),
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS),
BorderLayout.CENTER);
add(topPanel, BorderLayout.NORTH);
}

View File

@ -28,8 +28,8 @@ import javax.swing.JProgressBar;
import javax.swing.SwingWorker;
import javax.swing.Timer;
@SuppressWarnings("serial")
public class StatusBar extends JPanel implements PropertyChangeListener {
private static final long serialVersionUID = 1L;
private JProgressBar progressBar;
private JProgressBar memoryBar;
private JLabel messageText;
@ -76,6 +76,7 @@ public class StatusBar extends JPanel implements PropertyChangeListener {
/**
* Invoked when task's progress property changes.
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
if ("progress".equals(evt.getPropertyName())) {
progressBar.setValue((Integer)evt.getNewValue());
@ -138,7 +139,7 @@ public class StatusBar extends JPanel implements PropertyChangeListener {
long usedMemory = totalMemory-jvm.freeMemory();
int usedPct = (int)((100*usedMemory)/totalMemory);
bar.setForeground(getColor(usedPct));
bar.setValue((int)usedPct);
bar.setValue(usedPct);
bar.setString(usedPct + "% (" + mb(usedMemory) + "/" + mb(totalMemory) + "MB) ");
}

View File

@ -37,6 +37,8 @@ import javax.swing.SwingWorker;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.apache.openjpa.lib.jdbc.SQLFormatter;
import jpa.tools.swing.EntityDataModel;
import jpa.tools.swing.EntityTable;
import jpa.tools.swing.EntityTableView;
@ -50,8 +52,6 @@ import openbook.domain.ShoppingCart;
import openbook.server.OpenBookService;
import openbook.server.QueryDecorator;
import org.apache.openjpa.lib.jdbc.SQLFormatter;
/**
* A visual page coordinates the following functions of {@link OpenBookService} :
* <li>query for books
@ -71,8 +71,8 @@ import org.apache.openjpa.lib.jdbc.SQLFormatter;
*
* @author Pinaki Poddar
*/
@SuppressWarnings("serial")
public final class BuyBookPage extends JPanel {
private static final long serialVersionUID = 1L;
private final OpenBookService _service;
private final Customer _customer;
private final SearchPanel _searchPanel;
@ -124,6 +124,8 @@ public final class BuyBookPage extends JPanel {
*
*/
class SearchPanel extends JPanel implements ActionListener {
private static final long serialVersionUID = 1L;
private final JTextField _title = new JTextField("", 20);
private final JTextField _author = new JTextField("", 20);
private final JTextField _maxPrice = new JTextField("", 6);
@ -208,6 +210,7 @@ public final class BuyBookPage extends JPanel {
*
* The query is executed in a background, non-AWT thread.
*/
@Override
public void actionPerformed(ActionEvent e) {
new SwingWorker<List<Book>, Void>() {
private String queryString;
@ -260,6 +263,8 @@ public final class BuyBookPage extends JPanel {
*
*/
class SelectBookPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final JLabel _bookCount;
private final EntityTableView<Book> _selectedBooks;
@ -267,7 +272,7 @@ public final class BuyBookPage extends JPanel {
setLayout(new BorderLayout());
setBorder(BorderFactory.createTitledBorder(title));
_selectedBooks = new EntityTableView<Book>(Book.class,
_selectedBooks = new EntityTableView<>(Book.class,
EntityDataModel.BASIC_ATTR | EntityDataModel.ROW_COUNT,
_service.getUnit());
_bookCount = new JLabel();
@ -290,6 +295,8 @@ public final class BuyBookPage extends JPanel {
*
*/
class BuyPanel extends JPanel implements ListSelectionListener {
private static final long serialVersionUID = 1L;
JLabel _bookTitle;
JLabel _bookAuthors;
JLabel _bookPrice;
@ -385,6 +392,8 @@ public final class BuyBookPage extends JPanel {
*
*/
class ShoppingCartPanel extends JPanel implements ActionListener {
private static final long serialVersionUID = 1L;
private static final int MAX_ITEMS = 10;
private final ShoppingCart _cart;
private final JButton _placeOrder;

View File

@ -40,8 +40,8 @@ import openbook.server.OpenBookService;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class DeliveryPage extends JPanel {
private static final long serialVersionUID = 1L;
private final JButton _deliver;
private EntityTableView<PurchaseOrder> _orders;
private final OpenBookService _service;
@ -55,7 +55,7 @@ public class DeliveryPage extends JPanel {
_service = service;
_orders = new EntityTableView<PurchaseOrder>(PurchaseOrder.class, getOrders(PurchaseOrder.Status.PENDING),
_orders = new EntityTableView<>(PurchaseOrder.class, getOrders(PurchaseOrder.Status.PENDING),
EntityDataModel.ALL_ATTR, service.getUnit());
_title = new JLabel(_orders.getDataModel().getRowCount() + " " + PurchaseOrder.Status.PENDING
@ -116,7 +116,7 @@ public class DeliveryPage extends JPanel {
new SwingWorker<List<PurchaseOrder>, Void>() {
@Override
protected List<PurchaseOrder> doInBackground() throws Exception {
List<PurchaseOrder> updated = new ArrayList<PurchaseOrder>();
List<PurchaseOrder> updated = new ArrayList<>();
EntityDataModel<PurchaseOrder> orders = _orders.getDataModel();
int n = orders.getRowCount();
for (int i = 0; i < n; i++) {

View File

@ -52,6 +52,10 @@ import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import org.apache.openjpa.conf.OpenJPAVersion;
import org.apache.openjpa.lib.jdbc.JDBCListener;
import org.apache.openjpa.persistence.OpenJPAPersistence;
import jpa.tools.swing.AttributeLegendView;
import jpa.tools.swing.ConfigurationViewer;
import jpa.tools.swing.ErrorDialog;
@ -67,18 +71,14 @@ import openbook.server.OpenBookService;
import openbook.server.ServiceFactory;
import openbook.util.PropertyHelper;
import org.apache.openjpa.conf.OpenJPAVersion;
import org.apache.openjpa.lib.jdbc.JDBCListener;
import org.apache.openjpa.persistence.OpenJPAPersistence;
/**
* A graphical user interface based client of OpenBooks for demonstration.
*
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class Demo extends JFrame {
private static final long serialVersionUID = 1L;
private static Dimension TAB_VIEW = new Dimension(800,600);
private static Dimension OUT_VIEW = new Dimension(800,200);
private static Dimension NAV_VIEW = new Dimension(400,800);
@ -124,6 +124,7 @@ public class Demo extends JFrame {
SwingHelper.setLookAndFeel(14);
adjustWidgetSize();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Demo demo = Demo.getInstance();
demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -207,7 +208,7 @@ public class Demo extends JFrame {
SwingWorker<OpenBookService, Void> getService = new SwingWorker<OpenBookService, Void> () {
@Override
protected OpenBookService doInBackground() throws Exception {
Map<String, Object> runtimeConfig = new HashMap<String, Object>();
Map<String, Object> runtimeConfig = new HashMap<>();
runtimeConfig.put("openjpa.jdbc.JDBCListeners", new JDBCListener[]{_sqlListener});
OpenBookService service = ServiceFactory.getService(unitName, runtimeConfig);
service.initialize(null);
@ -302,6 +303,9 @@ public class Demo extends JFrame {
*
*/
public abstract class OpenBookAction extends AbstractAction {
private static final long serialVersionUID = 1L;
public OpenBookAction(String name, Icon icon, String tooltip) {
putValue(Action.NAME, name);
putValue(Action.SHORT_DESCRIPTION, tooltip);
@ -310,11 +314,14 @@ public class Demo extends JFrame {
}
public class BuyBookAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
BuyBookPage _buyBookPage;
public BuyBookAction(String name, Icon icon, String tooltip) {
super(name, icon, tooltip);
}
@Override
public void actionPerformed(ActionEvent e) {
if (_buyBookPage == null) {
_buyBookPage = new BuyBookPage(getService(), getCustomer());
@ -325,10 +332,13 @@ public class Demo extends JFrame {
}
public class DeliveryAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
DeliveryPage _deliveryPage;
public DeliveryAction(String name, Icon icon, String tooltip) {
super(name, icon, tooltip);
}
@Override
public void actionPerformed(ActionEvent e) {
if (_deliveryPage == null) {
_deliveryPage = new DeliveryPage(getService());
@ -340,10 +350,13 @@ public class Demo extends JFrame {
}
public class SupplyAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
SupplyPage _supplyPage;
public SupplyAction(String name, Icon icon, String tooltip) {
super(name, icon, tooltip);
}
@Override
public void actionPerformed(ActionEvent e) {
if (_supplyPage == null) {
_supplyPage = new SupplyPage(getService());
@ -355,10 +368,13 @@ public class Demo extends JFrame {
}
public class ViewConfigAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
ConfigurationViewer _configView;
public ViewConfigAction(String name, Icon icon, String tooltip) {
super(name, icon, tooltip);
}
@Override
public void actionPerformed(ActionEvent e) {
if (_configView == null) {
_configView = new ConfigurationViewer("Unit Configuration", getService().getUnit().getProperties());
@ -371,11 +387,14 @@ public class Demo extends JFrame {
}
public class ViewDomainAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
MetamodelView _domainView;
AttributeLegendView _legends;
public ViewDomainAction(String name, Icon icon, String tooltip) {
super(name, icon, tooltip);
}
@Override
public void actionPerformed(ActionEvent e) {
if (_domainView == null) {
_domainView = new MetamodelView(getService().getUnit().getMetamodel());
@ -388,9 +407,12 @@ public class Demo extends JFrame {
}
public class ViewDataAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
public ViewDataAction(String name, Icon icon, String tooltip) {
super(name, icon, tooltip);
}
@Override
public void actionPerformed(ActionEvent e) {
showTab(_tabbedPane, "Buy Books", null);
}
@ -398,10 +420,13 @@ public class Demo extends JFrame {
}
public class ViewQueryCacheAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
PreparedQueryViewer _queryView;
public ViewQueryCacheAction(String name, Icon icon, String tooltip) {
super(name, icon, tooltip);
}
@Override
public void actionPerformed(ActionEvent e) {
if (_queryView == null) {
_queryView = new PreparedQueryViewer(OpenJPAPersistence.cast(getService().getUnit()));
@ -413,10 +438,14 @@ public class Demo extends JFrame {
}
public class ViewSourceAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
public ViewSourceAction(String name, Icon icon, String tooltip) {
super(name, icon, tooltip);
}
@Override
public void actionPerformed(ActionEvent e) {
getSourceCodeBrowser();
}
@ -427,6 +456,8 @@ public class Demo extends JFrame {
*
*/
public class ShowCodeAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
private String _key;
private String _page;
@ -439,6 +470,7 @@ public class Demo extends JFrame {
_page = page;
}
@Override
public void actionPerformed(ActionEvent e) {
getSourceCodeBrowser().showPage(_key, _page);
}
@ -451,6 +483,8 @@ public class Demo extends JFrame {
*
*/
public class WelcomeAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
PowerPointViewer _powerpoint;
JLabel _logoLabel = new JLabel(Images.LOGO_OPENBOOKS);
boolean _showPresentation = true;
@ -459,6 +493,7 @@ public class Demo extends JFrame {
super(name, icon, tooltip);
}
@Override
public void actionPerformed(ActionEvent e) {
if (_powerpoint == null && _showPresentation) {
String dir = getConfiguration("openbook.slides.dir", "slides/");
@ -493,12 +528,15 @@ public class Demo extends JFrame {
}
public class AboutAction extends OpenBookAction {
private static final long serialVersionUID = 1L;
AboutDialog _dialog;
public AboutAction(String name, Icon icon, String tooltip) {
super(name, icon, tooltip);
}
@Override
public void actionPerformed(ActionEvent e) {
if (_dialog == null) {
_dialog = new AboutDialog(Images.LOGO_OPENBOOKS);
@ -605,6 +643,7 @@ public class Demo extends JFrame {
tree.setShowsRootHandles(true);
tree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
Object treeNode = _navigator.getLastSelectedPathComponent();
if (treeNode instanceof ActionTreeNode) {
@ -628,11 +667,14 @@ public class Demo extends JFrame {
*
*/
public static class ActionTreeNode extends DefaultMutableTreeNode {
private static final long serialVersionUID = 1L;
private final Action _action;
public ActionTreeNode(Action action) {
_action = action;
}
@Override
public String toString() {
return _action.getValue(Action.SHORT_DESCRIPTION).toString();
}
@ -640,6 +682,9 @@ public class Demo extends JFrame {
}
public class TypedTreeCellRenderer extends DefaultTreeCellRenderer {
private static final long serialVersionUID = 1L;
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
@ -648,6 +693,9 @@ public class Demo extends JFrame {
}
public static class AboutDialog extends JDialog {
private static final long serialVersionUID = 1L;
public AboutDialog(Icon logo) {
setModal(true);
setLayout(new BorderLayout());

View File

@ -38,6 +38,7 @@ public class ErrorHandler implements Thread.UncaughtExceptionHandler{
uncaughtException(Thread.currentThread(), e);
}
@Override
public void uncaughtException(Thread t, Throwable e) {
if (SwingUtilities.isEventDispatchThread()) {
new ErrorDialog(null, Images.ERROR, e).setVisible(true);

View File

@ -30,7 +30,7 @@ import javax.swing.ImageIcon;
*/
public class Images {
private static Map<String, Icon> images = new HashMap<String, Icon>();
private static Map<String, Icon> images = new HashMap<>();
public static Icon NEXT = getIcon("images/arrow_right.jpg", 24, -1);
public static Icon BACK = getIcon("images/arrow_left.jpg", 24, -1);

View File

@ -22,13 +22,11 @@ import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import jpa.tools.swing.GraphicOutputStream;
import org.apache.openjpa.lib.jdbc.AbstractJDBCListener;
import org.apache.openjpa.lib.jdbc.JDBCEvent;
import jpa.tools.swing.GraphicOutputStream;
/**
* Logs SQL statement to a graphic console.
*
@ -59,6 +57,7 @@ public class SQLLogger extends AbstractJDBCListener {
if (out == null)
return;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
out.println(event.getSQL());
}

View File

@ -39,8 +39,9 @@ import openbook.server.OpenBookService;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class SupplyPage extends JPanel {
private static final long serialVersionUID = 1L;
private final OpenBookService _service;
private final EntityTableView<Inventory> _lowInventories;
@ -62,7 +63,7 @@ public class SupplyPage extends JPanel {
_supply = new JButton("Supply " + REORDER_QUANTITY + " to each item");
List<Inventory> orders = getInventory(REORDER_LIMIT);
_lowInventories = new EntityTableView<Inventory>(Inventory.class,
_lowInventories = new EntityTableView<>(Inventory.class,
orders,
EntityDataModel.BASIC_ATTR | EntityDataModel.ASSOCIATION_ATTR,
service.getUnit());
@ -76,6 +77,7 @@ public class SupplyPage extends JPanel {
_view.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
_lowInventories.getDataModel().updateData(getInventory(REORDER_LIMIT));
}
@ -91,7 +93,7 @@ public class SupplyPage extends JPanel {
@Override
protected List<Inventory> doInBackground() throws Exception {
EntityDataModel<Inventory> invs = _lowInventories.getDataModel();
List<Inventory> updated = new ArrayList<Inventory>();
List<Inventory> updated = new ArrayList<>();
for (Inventory inv : invs) {
Book supplied = _service.supply(inv.getBook(), REORDER_QUANTITY);
updated.add(supplied.getInventory());
@ -99,6 +101,7 @@ public class SupplyPage extends JPanel {
return updated;
}
@Override
public void done() {
try {
_lowInventories.getDataModel().updateData(get(1, TimeUnit.SECONDS));

View File

@ -67,7 +67,7 @@ public class Author {
public void addBook(Book book) {
if (books == null)
books = new HashSet<Book>();
books = new HashSet<>();
books.add(book);
}

View File

@ -44,9 +44,10 @@ import javax.persistence.Version;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
@Entity
public class Book implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String ISBN;
@ -108,7 +109,7 @@ public class Book implements Serializable {
public void addAuthor(Author...authors) {
if (this.authors == null)
this.authors = new ArrayList<Author>();
this.authors = new ArrayList<>();
for (Author a : authors) {
if (!this.authors.contains(a))
this.authors.add(a);

View File

@ -32,9 +32,9 @@ import javax.persistence.Version;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
@Entity
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private long id;
@ -71,6 +71,7 @@ public class Customer implements Serializable {
return new ShoppingCart(this);
}
@Override
public String toString() {
return name;
}

View File

@ -28,9 +28,10 @@ import javax.persistence.Version;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
@Entity
public class Inventory implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@OneToOne(fetch=FetchType.EAGER, optional=false)
private Book book;

View File

@ -32,10 +32,11 @@ import javax.persistence.OrderColumn;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
@Entity
@IdClass(LineItem.LineItemId.class)
public class LineItem implements Serializable {
private static final long serialVersionUID = 1L;
/**
* <A name="order">
* An example of a compound derived identity.
@ -122,6 +123,8 @@ public class LineItem implements Serializable {
*
*/
public static class LineItemId implements Serializable {
private static final long serialVersionUID = 1L;
long order;
int index;

View File

@ -54,9 +54,10 @@ import javax.persistence.TemporalType;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
@Entity
public class PurchaseOrder implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Enumerates the status of a Purchase Order.
*
@ -195,7 +196,7 @@ public class PurchaseOrder implements Serializable {
throw new IllegalArgumentException("Can not add Line Item to Purchase Order for negative (=" +
quantity + ") number of Book " + book);
if (items == null)
items = new ArrayList<LineItem>();
items = new ArrayList<>();
items.add(new LineItem(this, items.size()+1, book, quantity));
total += (book.getPrice() * quantity);
}

View File

@ -27,8 +27,9 @@ import java.util.Map;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class ShoppingCart implements Serializable {
private static final long serialVersionUID = 1L;
/**
* The owner of this cart.
*/
@ -47,7 +48,7 @@ public class ShoppingCart implements Serializable {
*/
ShoppingCart(Customer c) {
customer = c;
items = new HashMap<Book, Integer>();
items = new HashMap<>();
}
/**

View File

@ -33,7 +33,7 @@ import openbook.domain.ShoppingCart;
*
*/
public interface OpenBookService {
public static final String DEFAULT_UNIT_NAME = "OpenBooks";
String DEFAULT_UNIT_NAME = "OpenBooks";
/**
* Starts a session for the given named Customer.
@ -43,7 +43,7 @@ public interface OpenBookService {
*
* @return a Customer
*/
public Customer login(String name);
Customer login(String name);
/**
* Selects a list of Books matching the given conditions.
@ -56,7 +56,7 @@ public interface OpenBookService {
* @param author name of author
* @param decorators to modify the executable query such as its range.
*/
public List<Book> select(String title,
List<Book> select(String title,
Double min, Double max,
String author,
QueryDecorator...decorators);
@ -71,7 +71,7 @@ public interface OpenBookService {
* @param author name of author
* @param decorators to modify the executable query such as its range.
*/
public String getQuery(String title,
String getQuery(String title,
Double min, Double max,
String author);
@ -92,7 +92,7 @@ public interface OpenBookService {
* @param cart a non-empty cart.
* @return a PurchaseOrder for the content of the cart.
*/
public PurchaseOrder placeOrder(ShoppingCart cart);
PurchaseOrder placeOrder(ShoppingCart cart);
/**
* Delivers the given order. Delivery changes the status of the order, decrements
@ -102,7 +102,7 @@ public interface OpenBookService {
* @return the PurchaseOrder after delivery.
*
*/
public PurchaseOrder deliver(PurchaseOrder order);
PurchaseOrder deliver(PurchaseOrder order);
/**
* Add inventory of the given Book by the given quantity.
@ -112,7 +112,7 @@ public interface OpenBookService {
*
* @return the Book after incrementing its inventory.
*/
public Book supply(Book b, int quantity);
Book supply(Book b, int quantity);
/**
* Gets the list of orders of given status.
@ -121,7 +121,7 @@ public interface OpenBookService {
*
* @return list of orders sorted by their placement dates.
*/
public List<PurchaseOrder> getOrders(PurchaseOrder.Status status, Customer customer);
List<PurchaseOrder> getOrders(PurchaseOrder.Status status, Customer customer);
/**
@ -131,7 +131,7 @@ public interface OpenBookService {
*
* @return list of Books with inventory lower than the given limit.
*/
public List<Inventory> getReorderableBooks(int limit);
List<Inventory> getReorderableBooks(int limit);
/**
* Count the number of instances of the given persistent type.
@ -139,7 +139,7 @@ public interface OpenBookService {
* @param cls a persistent type.
* @return number of persistent entity of the given type.
*/
public long count(Class<?> cls);
long count(Class<?> cls);
/**
* Populates the underlying data repository with sample values, only if
@ -150,31 +150,31 @@ public interface OpenBookService {
*
* @return true if the repository is initialized by this invocation.
*/
public boolean initialize(Map<String,Object> loadParameters);
boolean initialize(Map<String,Object> loadParameters);
/**
* Cleans everything. Be careful.
*/
public void clean();
void clean();
/**
* Gets the underlying persistence unit.
*
*/
public EntityManagerFactory getUnit();
EntityManagerFactory getUnit();
/**
* Gets the name of the underlying persistence unit.
*
*/
public String getUnitName();
String getUnitName();
/**
* Affirms if the transaction on this persistence unit is managed by a container.
*
*/
public boolean isManaged();
boolean isManaged();
}

View File

@ -31,6 +31,8 @@ import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.EntityType;
import org.apache.openjpa.persistence.criteria.OpenJPACriteriaBuilder;
import openbook.domain.Author;
import openbook.domain.Author_;
import openbook.domain.Book;
@ -47,8 +49,6 @@ import openbook.domain.ShoppingCart;
import openbook.util.PropertyHelper;
import openbook.util.Randomizer;
import org.apache.openjpa.persistence.criteria.OpenJPACriteriaBuilder;
/**
* A demonstrative example of a transaction service with persistent entity using Java Persistence API.
* <br>
@ -67,9 +67,8 @@ import org.apache.openjpa.persistence.criteria.OpenJPACriteriaBuilder;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
class OpenBookServiceImpl extends PersistenceService implements OpenBookService {
private static final long serialVersionUID = 1L;
public static final int CUSTOMER_COUNT = 10;
public static final int BOOK_COUNT = 100;
public static final int AUTHOR_COUNT = 40;
@ -78,8 +77,8 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
/**
* Range of number of queries executed for a {@linkplain #shop() shopping} trip.
*/
public static final Range<Double> PRICE_RANGE = new Range<Double>(4.99, 120.99);
public static final Range<Integer> STOCK_RANGE = new Range<Integer>(5, 50);
public static final Range<Double> PRICE_RANGE = new Range<>(4.99, 120.99);
public static final Range<Integer> STOCK_RANGE = new Range<>(5, 50);
public static final int REORDER_LEVEL = 10;
OpenBookServiceImpl(String unit, EntityManagerFactory emf, boolean managed,
@ -93,6 +92,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
*
* @return true if new inventory is created. false otherwise.
*/
@Override
public boolean initialize(Map<String,Object> config) {
if (isInitialized()) {
return false;
@ -119,7 +119,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
em.persist(customer);
}
List<Author> allAuthors = new ArrayList<Author>();
List<Author> allAuthors = new ArrayList<>();
System.err.println("Creating " + nAuthor + " new Authors");
for (int i = 1; i <= nAuthor; i++) {
Author author = new Author();
@ -164,6 +164,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
*
* @return a Customer
*/
@Override
public Customer login(String name) {
EntityManager em = begin();
@ -191,6 +192,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
/**
* Find books that match title and price range.
*/
@Override
public List<Book> select(String title, Double minPrice, Double maxPrice, String author,
QueryDecorator...decorators) {
CriteriaQuery<Book> q = buildQuery(title, minPrice, maxPrice, author);
@ -208,6 +210,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
* But OpenJPA produces a readable form that is quite <em>similar</em> to
* equivalent JPQL.
*/
@Override
public String getQuery(String title, Double minPrice, Double maxPrice, String author) {
CriteriaQuery<Book> q = buildQuery(title, minPrice, maxPrice, author);
return q.toString();
@ -238,7 +241,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
q.select(book);
// Builds the predicates conditionally for the filled-in input fields
List<Predicate> predicates = new ArrayList<Predicate>();
List<Predicate> predicates = new ArrayList<>();
if (!isEmpty(title)) {
Predicate matchTitle = cb.like(book.get(Book_.title), title);
predicates.add(matchTitle);
@ -280,6 +283,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
* The transactions may fail because of either insufficient inventory or
* concurrent modification of the same inventory by {@link #supply(Book, int) the supplier}.
*/
@Override
public PurchaseOrder deliver(PurchaseOrder o) {
if (o.isDelivered())
return o;
@ -293,13 +297,14 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
return o;
}
@Override
public List<PurchaseOrder> getOrders(PurchaseOrder.Status status, Customer customer) {
EntityManager em = begin();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<PurchaseOrder> q = cb.createQuery(PurchaseOrder.class);
Root<PurchaseOrder> order = q.from(PurchaseOrder.class);
q.select(order);
List<Predicate> predicates = new ArrayList<Predicate>();
List<Predicate> predicates = new ArrayList<>();
if (status != null) {
predicates.add(cb.equal(order.get(PurchaseOrder_.status), status));
}
@ -326,6 +331,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
*
* @param cart a non-null Shopping cart.
*/
@Override
public PurchaseOrder placeOrder(ShoppingCart cart) {
EntityManager em = begin();
PurchaseOrder order = new PurchaseOrder(cart);
@ -342,6 +348,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
* transaction. Some of the transactions may fail due to concurrent modification on
* the {@linkplain Inventory} by the {@linkplain #deliver() delivery} process.
*/
@Override
public Book supply(Book b, int quantity) {
EntityManager em = begin();
b = em.merge(b);
@ -350,6 +357,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
return b;
}
@Override
public List<Inventory> getReorderableBooks(int limit) {
EntityManager em = begin();
CriteriaBuilder cb = em.getCriteriaBuilder();
@ -368,6 +376,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
return result;
}
@Override
public long count(Class<?> cls) {
EntityManager em = getEntityManager();
CriteriaBuilder cb = em.getCriteriaBuilder();
@ -391,6 +400,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
return result;
}
@Override
public <T> List<T> getExtent(Class<T> entityClass) {
EntityManager em = begin();
CriteriaQuery<T> c = em.getCriteriaBuilder().createQuery(entityClass);
@ -400,6 +410,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
return result;
}
@Override
public <T> List<T> query(String jpql, Class<T> resultClass, QueryDecorator... decorators) {
EntityManager em = begin();
TypedQuery<T> query = em.createQuery(jpql, resultClass);
@ -413,6 +424,7 @@ class OpenBookServiceImpl extends PersistenceService implements OpenBookService
return result;
}
@Override
public void clean() {
EntityManager em = begin();
Set<EntityType<?>> entities = em.getMetamodel().getEntities();

View File

@ -32,14 +32,14 @@ import javax.persistence.PersistenceContextType;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
abstract class PersistenceService implements Serializable {
private static final long serialVersionUID = 1L;
private final EntityManagerFactory emf;
private final String unitName;
private final boolean isManaged;
private final PersistenceContextType scope;
private ThreadLocal<EntityManager> thread = new ThreadLocal<EntityManager>();
private ThreadLocal<EntityManager> thread = new ThreadLocal<>();
private ReentrantLock lock = new ReentrantLock();
protected PersistenceService(String unit, EntityManagerFactory emf, boolean managed,

View File

@ -28,7 +28,7 @@ import javax.persistence.PersistenceContextType;
*
*/
public class ServiceFactory {
private static final Map<String, OpenBookService> _services = new HashMap<String, OpenBookService>();
private static final Map<String, OpenBookService> _services = new HashMap<>();
public synchronized static OpenBookService getService(String unit) {
return getService(unit, null);

View File

@ -36,8 +36,8 @@ import java.util.Set;
*
*/
public class CommandProcessor {
private final Map<Option, String> registeredOptions = new HashMap<Option,String>();
private final Set<Option> unregisteredOptions = new HashSet<Option>();
private final Map<Option, String> registeredOptions = new HashMap<>();
private final Set<Option> unregisteredOptions = new HashSet<>();
private boolean allowsUnregisteredOption = true;
/**
@ -348,6 +348,7 @@ public class CommandProcessor {
return defValue;
}
@Override
public String toString() {
return getName();
}

View File

@ -22,12 +22,12 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import openbook.tools.converter.Java2HTMLConverter;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.taskdefs.MatchingTask;
import openbook.tools.converter.Java2HTMLConverter;
/**
* An ant task to run {@linkplain Java2HTMLConverter Java2HTML Converter}.
*
@ -46,7 +46,7 @@ public class Java2HTMLConverterTask extends MatchingTask {
private String lineNumberFormat = "%04d";
private boolean verbose = false;
private List<Arg> _args = new ArrayList<Arg>();
private List<Arg> _args = new ArrayList<>();
public String getSourcepath() {
return sourcepath;
@ -59,7 +59,7 @@ public class Java2HTMLConverterTask extends MatchingTask {
@Override
public void execute() throws BuildException {
List<String> files = getFiles();
List<String> args = new ArrayList<String>();
List<String> args = new ArrayList<>();
args.add("-sourcepath"); args.add(sourcepath);
args.add("-d"); args.add(destDir);
args.add("-extension"); args.add(extension);
@ -87,7 +87,7 @@ public class Java2HTMLConverterTask extends MatchingTask {
}
List<String> getFiles() {
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
DirectoryScanner scanner = getDirectoryScanner(new File(getSourcepath()));
String[] files = scanner.getIncludedFiles();
for (String file : files) {

View File

@ -21,11 +21,11 @@ package openbook.tools.converter;
import java.util.HashSet;
import java.util.Set;
import org.antlr.runtime.Token;
import openbook.tools.parser.JavaParser;
import openbook.tools.util.TextProcessingUtility;
import org.antlr.runtime.Token;
/**
* Renders Java source tokens as HTML tags.
* This renderer renders the parsed Java tokens with HTML styles.
@ -81,7 +81,7 @@ public class HTMLTokenRenderer implements TokenRenderer {
public static final String CSS_DECIMAL = "decimal";
public static final String CSS_LINE_NO = "lineno";
private Set<String> customIdentifiers = new HashSet<String>();
private Set<String> customIdentifiers = new HashSet<>();
public static final String NEW_LINE = "\r\n";
public static final String HTML_BR_TAG = "<br>";
@ -90,6 +90,7 @@ public class HTMLTokenRenderer implements TokenRenderer {
/**
* Gets a end-of-line string: a HTML &lt;br&gt; tag followed by carriage return and line feed.
*/
@Override
public String endLine(int line) {
return addLineBreak ? HTML_BR_TAG + NEW_LINE : NEW_LINE;
}
@ -97,6 +98,7 @@ public class HTMLTokenRenderer implements TokenRenderer {
/**
* Gets a string for beginning of a new line.
*/
@Override
public String newLine(int line) {
String result = "";
if (showLineNumber) {
@ -187,6 +189,7 @@ public class HTMLTokenRenderer implements TokenRenderer {
/**
* Gets the opening &lt;BODY&gt; and &lt;HTML&gt; tags and the &lt;link type="stylesheet"&gt; clause.
*/
@Override
public String getPrologue() {
return insertLines(
"<HTML>",
@ -199,6 +202,7 @@ public class HTMLTokenRenderer implements TokenRenderer {
/**
* Gets the closing &lt;BODY&gt; and &lt;HTML&gt; tags
*/
@Override
public String getEpilogue() {
return insertLines(" ", "</BODY>", "</HTML>");
}

View File

@ -21,12 +21,12 @@ package openbook.tools.converter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import openbook.tools.parser.JavaParser;
import org.antlr.runtime.CommonToken;
import org.antlr.runtime.Token;
import org.antlr.runtime.debug.BlankDebugEventListener;
import openbook.tools.parser.JavaParser;
/**
* A token processor to render the ANTLR tokens.
*

View File

@ -31,22 +31,27 @@ public class PlainTokenRenderer implements TokenRenderer {
private boolean showLineNumber = true;
private String lineNumberFormat = "%04d";
@Override
public String endLine(int line) {
return EMPTY;
}
@Override
public String newLine(int line) {
return showLineNumber ? String.format(lineNumberFormat, line) : EMPTY;
}
@Override
public String render(int decision, Token token) {
return token.getText();
}
@Override
public String getEpilogue() {
return EMPTY;
}
@Override
public String getPrologue() {
return EMPTY;
}

View File

@ -24,14 +24,14 @@ import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import openbook.tools.CommandProcessor;
import openbook.tools.parser.JavaLexer;
import openbook.tools.parser.JavaParser;
import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.debug.DebugEventListener;
import openbook.tools.CommandProcessor;
import openbook.tools.parser.JavaLexer;
import openbook.tools.parser.JavaParser;
/**
* Renders Java Source Code.
*

View File

@ -56,14 +56,14 @@ public interface TokenRenderer {
* A HTML render using a Cascaded Style Sheet may additionally specify
* the <HEAD> tag to include the style sheet.
*/
public String getPrologue();
String getPrologue();
/**
* Gets a string to be added after token processing ends.
* For example, a HTML renderer may return the closing HTML and BODY tags.
*
*/
public String getEpilogue();
String getEpilogue();
/**
* Produce a string representation of the given token.
@ -76,7 +76,7 @@ public interface TokenRenderer {
*
* @return a string representation of the given token.
*/
public String render(int decision, Token token);
String render(int decision, Token token);
/**
* Produce a string to signal beginning of a line.
@ -87,7 +87,7 @@ public interface TokenRenderer {
*
* @return a String can be a blank
*/
public String newLine(int line);
String newLine(int line);
/**
@ -99,5 +99,5 @@ public interface TokenRenderer {
*
* @return a String can be a blank
*/
public String endLine(int line);
String endLine(int line);
}

View File

@ -19,7 +19,15 @@
package openbook.tools.parser;
// $ANTLR 3.2 Sep 23, 2009 12:02:23 Java.g 2010-05-15 01:06:38
import org.antlr.runtime.*;
import org.antlr.runtime.BaseRecognizer;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.DFA;
import org.antlr.runtime.EarlyExitException;
import org.antlr.runtime.Lexer;
import org.antlr.runtime.MismatchedSetException;
import org.antlr.runtime.NoViableAltException;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.RecognizerSharedState;
public class JavaLexer extends Lexer {
public static final int T__29=29;
@ -149,6 +157,7 @@ public class JavaLexer extends Lexer {
super(input,state);
}
@Override
public String getGrammarFileName() { return "Java.g"; }
// $ANTLR start "T__25"
@ -3337,6 +3346,7 @@ public class JavaLexer extends Lexer {
}
// $ANTLR end "LINE_COMMENT"
@Override
public void mTokens() throws RecognitionException {
// Java.g:1:8: ( T__25 | T__26 | T__27 | T__28 | T__29 | T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | T__47 | T__48 | T__49 | T__50 | T__51 | T__52 | T__53 | T__54 | T__55 | T__56 | T__57 | T__58 | T__59 | T__60 | T__61 | T__62 | T__63 | T__64 | T__65 | T__66 | T__67 | T__68 | T__69 | T__70 | T__71 | T__72 | T__73 | T__74 | T__75 | T__76 | T__77 | T__78 | T__79 | T__80 | T__81 | T__82 | T__83 | T__84 | T__85 | T__86 | T__87 | T__88 | T__89 | T__90 | T__91 | T__92 | T__93 | T__94 | T__95 | T__96 | T__97 | T__98 | T__99 | T__100 | T__101 | T__102 | T__103 | T__104 | T__105 | T__106 | T__107 | T__108 | T__109 | T__110 | T__111 | T__112 | T__113 | HexLiteral | DecimalLiteral | OctalLiteral | FloatingPointLiteral | CharacterLiteral | StringLiteral | ENUM | ASSERT | Identifier | WS | COMMENT | LINE_COMMENT )
int alt29=101;
@ -4108,6 +4118,7 @@ public class JavaLexer extends Lexer {
this.special = DFA18_special;
this.transition = DFA18_transition;
}
@Override
public String getDescription() {
return "921:1: FloatingPointLiteral : ( ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( Exponent )? ( FloatTypeSuffix )? | '.' ( '0' .. '9' )+ ( Exponent )? ( FloatTypeSuffix )? | ( '0' .. '9' )+ Exponent ( FloatTypeSuffix )? | ( '0' .. '9' )+ FloatTypeSuffix );";
}
@ -4756,6 +4767,7 @@ public class JavaLexer extends Lexer {
this.special = DFA29_special;
this.transition = DFA29_transition;
}
@Override
public String getDescription() {
return "1:1: Tokens : ( T__25 | T__26 | T__27 | T__28 | T__29 | T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | T__47 | T__48 | T__49 | T__50 | T__51 | T__52 | T__53 | T__54 | T__55 | T__56 | T__57 | T__58 | T__59 | T__60 | T__61 | T__62 | T__63 | T__64 | T__65 | T__66 | T__67 | T__68 | T__69 | T__70 | T__71 | T__72 | T__73 | T__74 | T__75 | T__76 | T__77 | T__78 | T__79 | T__80 | T__81 | T__82 | T__83 | T__84 | T__85 | T__86 | T__87 | T__88 | T__89 | T__90 | T__91 | T__92 | T__93 | T__94 | T__95 | T__96 | T__97 | T__98 | T__99 | T__100 | T__101 | T__102 | T__103 | T__104 | T__105 | T__106 | T__107 | T__108 | T__109 | T__110 | T__111 | T__112 | T__113 | HexLiteral | DecimalLiteral | OctalLiteral | FloatingPointLiteral | CharacterLiteral | StringLiteral | ENUM | ASSERT | Identifier | WS | COMMENT | LINE_COMMENT );";
}

View File

@ -19,10 +19,24 @@
package openbook.tools.parser;
// $ANTLR 3.2 Sep 23, 2009 12:02:23 Java.g 2010-05-15 01:06:37
import org.antlr.runtime.*;
import java.util.HashMap;
import org.antlr.runtime.debug.*;
import java.io.IOException;
import java.util.HashMap;
import org.antlr.runtime.BaseRecognizer;
import org.antlr.runtime.BitSet;
import org.antlr.runtime.DFA;
import org.antlr.runtime.EarlyExitException;
import org.antlr.runtime.FailedPredicateException;
import org.antlr.runtime.IntStream;
import org.antlr.runtime.MismatchedSetException;
import org.antlr.runtime.NoViableAltException;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.RecognizerSharedState;
import org.antlr.runtime.Token;
import org.antlr.runtime.TokenStream;
import org.antlr.runtime.debug.DebugEventListener;
import org.antlr.runtime.debug.DebugEventSocketProxy;
import org.antlr.runtime.debug.DebugParser;
/** A Java 1.5 grammar for ANTLR v3 derived from the spec
*
@ -422,7 +436,9 @@ public class JavaParser extends DebugParser {
}
@Override
public String[] getTokenNames() { return JavaParser.tokenNames; }
@Override
public String getGrammarFileName() { return "Java.g"; }
@ -16773,12 +16789,15 @@ public class JavaParser extends DebugParser {
this.special = DFA8_special;
this.transition = DFA8_transition;
}
@Override
public String getDescription() {
return "177:1: compilationUnit : ( annotations ( packageDeclaration ( importDeclaration )* ( typeDeclaration )* | classOrInterfaceDeclaration ( typeDeclaration )* ) | ( packageDeclaration )? ( importDeclaration )* ( typeDeclaration )* );";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -16901,12 +16920,15 @@ public class JavaParser extends DebugParser {
this.special = DFA81_special;
this.transition = DFA81_transition;
}
@Override
public String getDescription() {
return "492:13: ( explicitConstructorInvocation )?";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -17174,12 +17196,15 @@ public class JavaParser extends DebugParser {
this.special = DFA85_special;
this.transition = DFA85_transition;
}
@Override
public String getDescription() {
return "495:1: explicitConstructorInvocation : ( ( nonWildcardTypeArguments )? ( 'this' | 'super' ) arguments ';' | primary '.' ( nonWildcardTypeArguments )? 'super' arguments ';' );";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -17315,12 +17340,15 @@ public class JavaParser extends DebugParser {
this.special = DFA106_special;
this.transition = DFA106_transition;
}
@Override
public String getDescription() {
return "600:1: blockStatement : ( localVariableDeclarationStatement | classOrInterfaceDeclaration | statement );";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -17461,9 +17489,11 @@ public class JavaParser extends DebugParser {
this.special = DFA114_special;
this.transition = DFA114_transition;
}
@Override
public String getDescription() {
return "618:1: statement : ( block | ASSERT expression ( ':' expression )? ';' | 'if' parExpression statement ( options {k=1; } : 'else' statement )? | 'for' '(' forControl ')' statement | 'while' parExpression statement | 'do' statement 'while' parExpression ';' | 'try' block ( catches 'finally' block | catches | 'finally' block ) | 'switch' parExpression '{' switchBlockStatementGroups '}' | 'synchronized' parExpression block | 'return' ( expression )? ';' | 'throw' expression ';' | 'break' ( Identifier )? ';' | 'continue' ( Identifier )? ';' | ';' | statementExpression ';' | Identifier ':' statement );";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@ -17659,12 +17689,15 @@ public class JavaParser extends DebugParser {
this.special = DFA123_special;
this.transition = DFA123_transition;
}
@Override
public String getDescription() {
return "671:1: forControl options {k=3; } : ( enhancedForControl | ( forInit )? ';' ( expression )? ';' ( forUpdate )? );";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -18089,12 +18122,15 @@ public class JavaParser extends DebugParser {
this.special = DFA124_special;
this.transition = DFA124_transition;
}
@Override
public String getDescription() {
return "677:1: forInit : ( localVariableDeclaration | expressionList );";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -18197,12 +18233,15 @@ public class JavaParser extends DebugParser {
this.special = DFA126_special;
this.transition = DFA126_transition;
}
@Override
public String getDescription() {
return "709:31: ( assignmentOperator expression )?";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -18441,12 +18480,15 @@ public class JavaParser extends DebugParser {
this.special = DFA127_special;
this.transition = DFA127_transition;
}
@Override
public String getDescription() {
return "712:1: assignmentOperator : ( '=' | '+=' | '-=' | '*=' | '/=' | '&=' | '|=' | '^=' | '%=' | ( '<' '<' '=' )=>t1= '<' t2= '<' t3= '=' {...}? | ( '>' '>' '>' '=' )=>t1= '>' t2= '>' t3= '>' t4= '=' {...}? | ( '>' '>' '=' )=>t1= '>' t2= '>' t3= '=' {...}?);";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -18577,12 +18619,15 @@ public class JavaParser extends DebugParser {
this.special = DFA139_special;
this.transition = DFA139_transition;
}
@Override
public String getDescription() {
return "792:1: shiftOp : ( ( '<' '<' )=>t1= '<' t2= '<' {...}? | ( '>' '>' '>' )=>t1= '>' t2= '>' t3= '>' {...}? | ( '>' '>' )=>t1= '>' t2= '>' {...}?);";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -18723,12 +18768,15 @@ public class JavaParser extends DebugParser {
this.special = DFA145_special;
this.transition = DFA145_transition;
}
@Override
public String getDescription() {
return "823:1: unaryExpressionNotPlusMinus : ( '~' unaryExpression | '!' unaryExpression | castExpression | primary ( selector )* ( '++' | '--' )? );";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -18808,12 +18856,15 @@ public class JavaParser extends DebugParser {
this.special = DFA146_special;
this.transition = DFA146_transition;
}
@Override
public String getDescription() {
return "832:12: ( type | expression )";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -18920,12 +18971,15 @@ public class JavaParser extends DebugParser {
this.special = DFA149_special;
this.transition = DFA149_transition;
}
@Override
public String getDescription() {
return "837:34: ( identifierSuffix )?";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -19047,12 +19101,15 @@ public class JavaParser extends DebugParser {
this.special = DFA151_special;
this.transition = DFA151_transition;
}
@Override
public String getDescription() {
return "841:38: ( identifierSuffix )?";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -19151,9 +19208,11 @@ public class JavaParser extends DebugParser {
this.special = DFA156_special;
this.transition = DFA156_transition;
}
@Override
public String getDescription() {
return "846:1: identifierSuffix : ( ( '[' ']' )+ '.' 'class' | ( '[' expression ']' )+ | arguments | '.' 'class' | '.' explicitGenericInvocation | '.' 'this' | '.' 'super' arguments | '.' 'new' innerCreator );";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@ -19237,12 +19296,15 @@ public class JavaParser extends DebugParser {
this.special = DFA155_special;
this.transition = DFA155_transition;
}
@Override
public String getDescription() {
return "()+ loopback of 848:9: ( '[' expression ']' )+";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;
@ -19349,12 +19411,15 @@ public class JavaParser extends DebugParser {
this.special = DFA162_special;
this.transition = DFA162_transition;
}
@Override
public String getDescription() {
return "()* loopback of 874:28: ( '[' expression ']' )*";
}
@Override
public void error(NoViableAltException nvae) {
dbg.recognitionException(nvae);
}
@Override
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
TokenStream input = (TokenStream)_input;
int _s = s;

View File

@ -70,7 +70,7 @@ public class URIUtils {
return uri;
}
String[] inputSegments = path.split("/");
Stack<String> outputSegments = new Stack<String>();
Stack<String> outputSegments = new Stack<>();
for (int i = 0; i < inputSegments.length; i++) {
if ((inputSegments[i].length() == 0) || (".".equals(inputSegments[i]))) {
// Do nothing

View File

@ -46,7 +46,7 @@ public class PropertyHelper {
*/
public static Map<String,Object> filter(Map<String,Object> props, String name, boolean prefix,
boolean includeArrays) {
Map<String, Object> result = new HashMap<String, Object>();
Map<String, Object> result = new HashMap<>();
for (String key : props.keySet()) {
if (key == null)
continue;
@ -82,14 +82,14 @@ public class PropertyHelper {
* @return key-value pairs that match.
*/
public static Map<String,List<Object>> filterArrayKeys(Map<String,Object> props, String name, boolean prefix) {
Map<String, List<Object>> result = new HashMap<String, List<Object>>();
Map<String, List<Object>> result = new HashMap<>();
for (String key : props.keySet()) {
boolean match = prefix ? key.startsWith(name) : (key.indexOf(name) != -1);
if (match && isArray(key)) {
String realKey = removeArray(key);
List<Object> values = result.get(realKey);
if (values == null) {
values = new ArrayList<Object>();
values = new ArrayList<>();
result.put(realKey, values);
}
values.add(props.get(key));
@ -137,7 +137,7 @@ public class PropertyHelper {
}
public static Map<String, Object> toMap(Properties p) {
Map<String, Object> result = new HashMap<String, Object>();
Map<String, Object> result = new HashMap<>();
for (Object k : p.keySet()) {
result.put(k.toString(), p.get(k));
}
@ -210,7 +210,7 @@ public class PropertyHelper {
List<String> pairs = getStringList(props, key);
if (pairs == null || pairs.isEmpty())
return def;
Map<String,String> result = new LinkedHashMap<String, String>();
Map<String,String> result = new LinkedHashMap<>();
for (String pair : pairs) {
int index = pair.indexOf("->");
if (index != -1) {
@ -250,7 +250,7 @@ public class PropertyHelper {
public static Set<String> getSubsectionKeys(Set<String> keys, String section) {
String prefix = asPrefix(section);
Set<String> subsections = new HashSet<String>();
Set<String> subsections = new HashSet<>();
for (String key : keys) {
if (key.startsWith(prefix)) {
subsections.add(prefix + getPrefix(key.substring(prefix.length())));
@ -292,7 +292,7 @@ public class PropertyHelper {
* @return the map with only the keys that starts with the given section.
*/
public static Map<String,Object> getSection(Map<String,Object> props, String section, boolean retain) {
Map<String,Object> result = new HashMap<String, Object>(props);
Map<String,Object> result = new HashMap<>(props);
Set<String> keys = props.keySet();
String prefix = asPrefix(section);
for (String key : keys) {

View File

@ -92,8 +92,8 @@ public class Randomizer {
public static <T> List<T> selectRandom(List<T> list, int n) {
if (list == null || list.isEmpty())
return Collections.emptyList();
Set<Integer> indices = new HashSet<Integer>();
List<T> selected = new ArrayList<T>();
Set<Integer> indices = new HashSet<>();
List<T> selected = new ArrayList<>();
int m = list.size();
if (n >= m) {
selected.addAll(list);

View File

@ -31,9 +31,9 @@ import javax.persistence.ManyToOne;
*
*/
@SuppressWarnings("serial")
@Entity
public class Ask extends Tradable {
private static final long serialVersionUID = 1L;
/**
* The trader who has made the offer.
* Must never be null.

View File

@ -30,9 +30,9 @@ import javax.persistence.ManyToOne;
*
*/
@SuppressWarnings("serial")
@Entity
public class Bid extends Tradable {
private static final long serialVersionUID = 1L;
/**
* The trader who has made the offer.
* Must never be null.

View File

@ -20,8 +20,8 @@ package org.apache.openjpa.trader.domain;
import java.io.Serializable;
@SuppressWarnings("serial")
public class LogStatement implements Serializable {
private static final long serialVersionUID = 1L;
private String level;
private String context;
private String thread;

View File

@ -28,8 +28,8 @@ import java.io.Serializable;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public class Match implements Serializable {
private static final long serialVersionUID = 1L;
private Ask ask;
private Bid bid;

View File

@ -31,9 +31,9 @@ import javax.persistence.Id;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
@Entity
public class Stock implements Serializable {
private static final long serialVersionUID = 1L;
/**
* The primary identity of a Stock.
* The uniqueness of the primary keys are often warranted by the persistence provider.

View File

@ -37,9 +37,9 @@ import javax.persistence.Version;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
@MappedSuperclass
public abstract class Tradable implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Primary identity of a traded entity.
* Its value is generated by the persistence provider.

View File

@ -27,9 +27,9 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
@SuppressWarnings("serial")
@Entity
public class Trade implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Primary identity of a committed trade.
* Its value is generated by the persistence provider.

View File

@ -26,12 +26,12 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
@SuppressWarnings("serial")
@Entity
@Table(name="TRADER",
uniqueConstraints= @UniqueConstraint(columnNames={"NAME"}))
public class Trader implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String name;

View File

@ -55,8 +55,8 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
*
* @author Pinaki Poddar
*/
@SuppressWarnings("serial")
public class TradingServiceAdapterImpl extends RemoteServiceServlet implements TradingServiceAdapter {
private static final long serialVersionUID = 1L;
private TradingService _del;
private ExceptionAdapter _translator = new ExceptionAdapter();

View File

@ -40,8 +40,8 @@ import org.apache.openjpa.trader.domain.Tradable;
import org.apache.openjpa.trader.domain.Trade;
import org.apache.openjpa.trader.domain.Trader;
@SuppressWarnings("serial")
public class Exchange extends PersistenceService implements TradingService {
private static final long serialVersionUID = 1L;
private BufferedLog log;
public Exchange(String unit) {

View File

@ -43,8 +43,8 @@ import org.apache.openjpa.persistence.OpenJPAPersistence;
* @author Pinaki Poddar
*
*/
@SuppressWarnings("serial")
public abstract class PersistenceService extends Observable implements Serializable {
private static final long serialVersionUID = 1L;
private final OpenJPAEntityManagerFactory emf;
private final String unitName;
private final boolean isManaged;

View File

@ -50,6 +50,7 @@ public class Address {
coordinates = c;
}
@Override
public String toString() {
return street + " " + city + ", " + state + " " + zip;
}

View File

@ -39,6 +39,7 @@ public class ContactInfo {
@Embedded
Phone homePhone;
@Override
public String toString() {
return homeAddress.toString() + " " + homePhone.toString();
}

View File

@ -37,6 +37,7 @@ public class Phone {
@Basic
private String type;
@Override
public String toString() {
return "type: " + type + " number:" + number;
}

View File

@ -44,7 +44,7 @@ public class User {
// Collection of embeddables
@ElementCollection
@CollectionTable(name = "user_addresses")
private Set<Address> addresses = new HashSet<Address>();
private Set<Address> addresses = new HashSet<>();
@Basic
private String user_name;
@ -65,6 +65,7 @@ public class User {
addresses.add(a);
}
@Override
public String toString() {
String res = user_name + " " + user + " " + contactInfo;

View File

@ -18,8 +18,12 @@
*/
package hellojpa;
import java.util.*;
import javax.persistence.*;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
/**

View File

@ -18,8 +18,11 @@
*/
package hellojpa;
import java.util.*;
import javax.persistence.*;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;
/**

View File

@ -25,11 +25,11 @@ import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
@ -75,6 +75,9 @@ import javax.persistence.OneToOne;
+ "and cousin2 = ?1 and cousin1 <> ?1")
})
public class Deity implements Serializable {
private static final long serialVersionUID = 1L;
// the Id is the name, which is generally a bad idea, but we are
// confident that diety names will be unique
@Id
@ -130,13 +133,13 @@ public class Deity implements Serializable {
// add the child to this member's children
if (children == null)
children = new HashSet<Deity>();
children = new HashSet<>();
children.add(child);
if (childFather != null) {
child.father = childFather;
if (childFather.children == null)
childFather.children = new HashSet<Deity>();
childFather.children = new HashSet<>();
childFather.children.add(child);
}

View File

@ -18,11 +18,16 @@
*/
package relations;
import java.util.*;
import javax.persistence.*;
// import the enums for MALE and FEMALE
import static relations.Deity.Gender.*;
import static relations.Deity.Gender.FEMALE;
import static relations.Deity.Gender.MALE;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
/**

View File

@ -159,6 +159,7 @@ public class AccountDataBean implements Serializable {
);
}
@Override
public String toString() {
return "\n\tAccount Data for account: " + getAccountID()
+ "\n\t\t loginCount:" + getLoginCount()

View File

@ -97,6 +97,7 @@ public class AccountProfileDataBean implements java.io.Serializable {
);
}
@Override
public String toString() {
return "\n\tAccount Profile Data for userID:" + getUserID()
+ "\n\t\t passwd:" + getPassword()

View File

@ -127,6 +127,7 @@ public class HoldingDataBean implements Serializable {
);
}
@Override
public String toString() {
return "\n\tHolding Data for holding: " + getHoldingID()
+ "\n\t\t quantity:" + getQuantity()

View File

@ -82,7 +82,8 @@ public class MarketSummaryDataBean implements Serializable
);
}
public String toString()
@Override
public String toString()
{
String ret = "\n\tMarket Summary at: " + getSummaryDate()
+ "\n\t\t TSIA:" + getTSIA()

View File

@ -179,6 +179,7 @@ public class OrderDataBean implements Serializable
);
}
@Override
public String toString()
{
return "Order " + getOrderID()

View File

@ -124,6 +124,7 @@ public class QuoteDataBean implements Serializable {
setSymbol(symbol);
}
@Override
public String toString() {
return "\n\tQuote Data for: " + getSymbol()
+ "\n\t\t companyName: " + getCompanyName()

View File

@ -47,7 +47,7 @@ public class TestDaytrader extends AbstractPersistenceTestCase {
// Mimic EM pooling
boolean poolEm = true;
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true,"
+ "SchemaAction='add,deleteTableContents')");
emf = createEmf("daytrader", map);
@ -105,7 +105,7 @@ public class TestDaytrader extends AbstractPersistenceTestCase {
private EntityManagerFactory createEmf(final String pu, Object... props) {
Map<String, Object> map = getPropertiesMap(props);
EntityManagerFactory emf = null;
Map<Object, Object> config = new HashMap<Object, Object>(System.getProperties());
Map<Object, Object> config = new HashMap<>(System.getProperties());
config.putAll(map);
emf = Persistence.createEntityManagerFactory(pu, config);
if (emf == null) {

View File

@ -17,10 +17,10 @@
package org.apache.openjpa.integration.daytrader;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.ArrayList;
import java.math.BigDecimal;
import javax.persistence.EntityManagerFactory;

View File

@ -93,8 +93,8 @@ public class TradeJPADirect {
// constructor for OpenJPA junit tests
public TradeJPADirect(Log log, EntityManagerFactory emf, boolean poolEm) {
this.log = log;
this.emf = emf;
TradeJPADirect.log = log;
TradeJPADirect.emf = emf;
_poolEm = poolEm;
if (initialized == false)
init();
@ -140,9 +140,9 @@ public class TradeJPADirect {
quotes = query.getResultList();
QuoteDataBean[] quoteArray = (QuoteDataBean[]) quotes.toArray(new QuoteDataBean[quotes.size()]);
ArrayList<QuoteDataBean> topGainers = new ArrayList<QuoteDataBean>(
ArrayList<QuoteDataBean> topGainers = new ArrayList<>(
5);
ArrayList<QuoteDataBean> topLosers = new ArrayList<QuoteDataBean>(5);
ArrayList<QuoteDataBean> topLosers = new ArrayList<>(5);
// BigDecimal TSIA = FinancialUtils.ZERO;
BigDecimal TSIA = (new BigDecimal(0.00)).setScale(2);
// BigDecimal openTSIA = FinancialUtils.ZERO;
@ -963,6 +963,7 @@ public class TradeJPADirect {
}
class quotePriceComparator implements java.util.Comparator {
@Override
public int compare(Object quote1, Object quote2) {
double change1 = ((QuoteDataBean) quote1).getChange();
double change2 = ((QuoteDataBean) quote2).getChange();

View File

@ -16,9 +16,9 @@
*/
package org.apache.openjpa.integration.daytrader;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.io.IOException;
/**
* TradeScenarioServlet emulates a population of web users by generating a specific Trade operation
@ -203,15 +203,15 @@ public class TradeScenario {
}
}
if (foundHoldingToSell) break;
tAction.log.warn("TradeScenario: No holdings sold for userID=" + userID +
TradeJPADirect.log.warn("TradeScenario: No holdings sold for userID=" + userID +
", holdings=" + numHoldings);
} else {
tAction.log.warn("TradeScenario: No holdings to sell for userID=" + userID);
TradeJPADirect.log.warn("TradeScenario: No holdings to sell for userID=" + userID);
}
// At this point: A TradeScenario Sell was requested with No Stocks in Portfolio
// This can happen when a new registered user happens to request a sell before a buy
// In this case, fall through and perform a buy instead
tAction.log.warn("TradeScenario: No holdings sold - switching to buy -- userID=" + userID);
TradeJPADirect.log.warn("TradeScenario: No holdings sold - switching to buy -- userID=" + userID);
/* Trade 2.037: Added sell_deficit counter to maintain correct buy/sell mix.
* When a users portfolio is reduced to 0 holdings, a buy is requested instead of a sell.
@ -236,14 +236,14 @@ public class TradeScenario {
}
private void log(StringBuilder sb, String msg) {
if (tAction.log != null && tAction.log.isTraceEnabled()) {
if (TradeJPADirect.log != null && TradeJPADirect.log.isTraceEnabled()) {
sb.append(msg);
sb.append(System.getProperty("line.separator"));
}
}
private void log(StringBuilder sb, String msg, Object obj) {
if (tAction.log != null && tAction.log.isTraceEnabled()) {
if (TradeJPADirect.log != null && TradeJPADirect.log.isTraceEnabled()) {
sb.append(msg);
sb.append(" = ");
sb.append(obj);

View File

@ -252,6 +252,7 @@ public class TestJMXPlatformMBeans extends AbstractPersistenceTestCase {
public class DCMBeanCallable implements Callable<Boolean> {
@Override
public Boolean call() {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
assertNotNull(mbs);
@ -314,6 +315,7 @@ public class TestJMXPlatformMBeans extends AbstractPersistenceTestCase {
setQueryMethod(queryMethod);
}
@Override
@SuppressWarnings("unchecked")
public Boolean call() {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

View File

@ -30,6 +30,7 @@ import org.apache.openjpa.persistence.test.SingleEMFTestCase;
public class TestLogFactory extends SingleEMFTestCase {
String systemPropLog = null;
@Override
public void setUp() throws Exception {
// Maven users may disable logging via a global system prop - which breaks this testcase.
systemPropLog = System.getProperty("openjpa.Log");
@ -37,6 +38,7 @@ public class TestLogFactory extends SingleEMFTestCase {
super.setUp();
}
@Override
public void tearDown() throws Exception {
super.tearDown();
if(systemPropLog != null) {
@ -61,6 +63,7 @@ public class TestLogFactory extends SingleEMFTestCase {
}
}
@Override
public String getPersistenceUnitName() {
// override puName instead of creating our own EMF.
// getLog uses the SingleEMFTestCase's emf.

View File

@ -26,9 +26,11 @@ import javax.persistence.spi.PersistenceProviderResolver;
public class DummyPersistenceProviderResolver implements
PersistenceProviderResolver {
@Override
public void clearCachedProviders() {
}
@Override
public List<PersistenceProvider> getPersistenceProviders() {
return null;
}

View File

@ -27,6 +27,7 @@ import javax.persistence.spi.ProviderUtil;
public class DummyProvider1 implements PersistenceProvider {
@Override
public EntityManagerFactory createContainerEntityManagerFactory(
PersistenceUnitInfo persistenceunitinfo, Map map) {
return null;
@ -42,10 +43,12 @@ public class DummyProvider1 implements PersistenceProvider {
return false;
}
@Override
public EntityManagerFactory createEntityManagerFactory(String s, Map map) {
return null;
}
@Override
public ProviderUtil getProviderUtil() {
return null;
}

View File

@ -27,6 +27,7 @@ import javax.persistence.spi.ProviderUtil;
public class DummyProvider2 implements PersistenceProvider {
@Override
public EntityManagerFactory createContainerEntityManagerFactory(
PersistenceUnitInfo persistenceunitinfo, Map map) {
return null;
@ -42,10 +43,12 @@ public class DummyProvider2 implements PersistenceProvider {
return false;
}
@Override
public EntityManagerFactory createEntityManagerFactory(String s, Map map) {
return null;
}
@Override
public ProviderUtil getProviderUtil() {
return null;
}

View File

@ -56,6 +56,7 @@ public class TestPersistenceProviderResolver extends TestCase {
ClassLoader originalLoader = null;
TempUrlLoader tempLoader = null;
@Override
public void setUp() throws Exception {
super.setUp();
@ -77,6 +78,7 @@ public class TestPersistenceProviderResolver extends TestCase {
originalLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
// Restore the original classloader, in case there was an exception
@ -84,7 +86,7 @@ public class TestPersistenceProviderResolver extends TestCase {
}
public void testDefault() {
List<String> providerNames = new LinkedList<String>();
List<String> providerNames = new LinkedList<>();
providerNames.add(openjpaProvider);
checkProviders(providerNames);
}
@ -99,7 +101,7 @@ public class TestPersistenceProviderResolver extends TestCase {
AccessController.doPrivileged(J2DoPrivHelper
.setContextClassLoaderAction(tempLoader));
List<String> providerNames = new LinkedList<String>();
List<String> providerNames = new LinkedList<>();
providerNames.add(openjpaProvider);
providerNames.add(dummyProvider1);
checkProviders(providerNames);
@ -118,7 +120,7 @@ public class TestPersistenceProviderResolver extends TestCase {
AccessController.doPrivileged(J2DoPrivHelper
.setContextClassLoaderAction(tempLoader));
List<String> providerNames = new LinkedList<String>();
List<String> providerNames = new LinkedList<>();
providerNames.add(openjpaProvider);
providerNames.add(dummyProvider1);
providerNames.add(dummyProvider2);
@ -136,7 +138,7 @@ public class TestPersistenceProviderResolver extends TestCase {
assertNotNull(providers);
resolver.clearCachedProviders();
List<String> providerNames = new LinkedList<String>();
List<String> providerNames = new LinkedList<>();
providerNames.add(openjpaProvider);
checkProviders(providerNames);
}

View File

@ -66,42 +66,52 @@ public class Address implements IAddress, Serializable {
private String phoneNumber;
@Override
public void setStreetAddress(String streetAddress) {
this.streetAddress = streetAddress;
}
@Override
public String getStreetAddress() {
return this.streetAddress;
}
@Override
public void setCity(String city) {
this.city = city;
}
@Override
public String getCity() {
return this.city;
}
@Override
public void setState(String state) {
this.state = state;
}
@Override
public String getState() {
return this.state;
}
@Override
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
@Override
public String getPostalCode() {
return this.postalCode;
}
@Override
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
@Override
public String getPhoneNumber() {
return this.phoneNumber;
}

View File

@ -19,6 +19,7 @@
package org.apache.openjpa.integration.validation;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

View File

@ -19,6 +19,7 @@
package org.apache.openjpa.integration.validation;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

View File

@ -110,7 +110,7 @@ public class ConstraintSize implements Serializable {
private void setInvalidMap() {
Map<String,String> m = new HashMap<String,String>();
Map<String,String> m = new HashMap<>();
m.put("a", "a value");
m.put("b", "b value");
m.put("c", "c value");
@ -118,7 +118,7 @@ public class ConstraintSize implements Serializable {
}
private void setValidMap() {
Map<String,String> m = new HashMap<String,String>();
Map<String,String> m = new HashMap<>();
m.put("a", "a value");
setMyMap(m);
}

View File

@ -37,19 +37,23 @@ public class Customer extends Person implements ICustomer, Serializable {
private Address billingAddress;
@Override
public void setShippingAddress(IAddress shippingAddress) {
this.shippingAddress = (Address) shippingAddress;
}
@Override
public IAddress getShippingAddress() {
return this.shippingAddress;
}
@Override
public void setBillingAddress(IAddress billingAddress) {
this.billingAddress = (Address) billingAddress;
}
@Override
public IAddress getBillingAddress() {
return this.billingAddress;
}

Some files were not shown because too many files have changed in this diff Show More