Skip to content

Commit

Permalink
Make checkstyle even happier
Browse files Browse the repository at this point in the history
  • Loading branch information
bafco authored and jharting committed Jul 18, 2013
1 parent 3029581 commit 812bef6
Show file tree
Hide file tree
Showing 27 changed files with 198 additions and 105 deletions.
Expand Up @@ -85,6 +85,7 @@ public String bookHotel(@QueryParam("hotel.id") String id,
@QueryParam("booking.creditCardName") String cardName,
@QueryParam("booking.creditCardExpiryMonth") String cardMonth,
@QueryParam("booking.creditCardExpiryYear") String cardYear) {
final String failure = "failure";
if (app.isValid()) {
for (HotelProvider provider : providers) {
for (Hotel h : provider.hotels()) {
Expand All @@ -93,13 +94,13 @@ public String bookHotel(@QueryParam("hotel.id") String id,
if (success) {
return "success";
} else {
return "failure";
return failure;
}
}
}
}
}
return "failure";
return failure;
}

@GET
Expand Down
Expand Up @@ -23,8 +23,10 @@
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.Ellipse2D;

import javax.swing.Icon;
import javax.swing.ImageIcon;

import org.jboss.weld.osgi.examples.paint.api.Shape;

public class Circle implements Shape {
Expand All @@ -47,14 +49,15 @@ public Icon getIcon() {

@Override
public void draw(Graphics2D g2, Point p) {
int x = p.x - 25;
int y = p.y - 25;
GradientPaint gradient = new GradientPaint(x, y, Color.RED, x + 50, y, Color.WHITE);
final int size = 50;
int x = p.x - size / 2;
int y = p.y - size / 2;
GradientPaint gradient = new GradientPaint(x, y, Color.RED, x + size, y, Color.WHITE);
g2.setPaint(gradient);
g2.fill(new Ellipse2D.Double(x, y, 50, 50));
g2.fill(new Ellipse2D.Double(x, y, size, size));
BasicStroke wideStroke = new BasicStroke(2.0f);
g2.setColor(Color.black);
g2.setStroke(wideStroke);
g2.draw(new Ellipse2D.Double(x, y, 50, 50));
g2.draw(new Ellipse2D.Double(x, y, size, size));
}
}
Expand Up @@ -53,6 +53,7 @@
@Singleton
public class PaintFrame extends JFrame implements MouseListener {

private static final int PANEL_MINIMAL_SIZE = 400;
private static final int BOX = 54;
private JToolBar toolbar;
private String selected;
Expand All @@ -79,12 +80,12 @@ public PaintFrame(Bundle bundle) {
panel = new JPanel();
panel.setBackground(Color.WHITE);
panel.setLayout(null);
panel.setMinimumSize(new Dimension(400, 400));
panel.setMinimumSize(new Dimension(PANEL_MINIMAL_SIZE, PANEL_MINIMAL_SIZE));
panel.addMouseListener(this);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(toolbar, BorderLayout.NORTH);
getContentPane().add(panel, BorderLayout.CENTER);
setSize(400, 400);
setSize(PANEL_MINIMAL_SIZE, PANEL_MINIMAL_SIZE);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.addWindowListener(new WindowAdapter() {
@Override
Expand Down
Expand Up @@ -23,8 +23,10 @@
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.Rectangle2D;

import javax.swing.Icon;
import javax.swing.ImageIcon;

import org.jboss.weld.osgi.examples.paint.api.Shape;

public class Square implements Shape {
Expand All @@ -47,14 +49,15 @@ public Icon getIcon() {

@Override
public void draw(Graphics2D g2, Point p) {
int x = p.x - 25;
int y = p.y - 25;
GradientPaint gradient = new GradientPaint(x, y, Color.BLUE, x + 50, y, Color.WHITE);
final int size = 50;
int x = p.x - size / 2;
int y = p.y - size / 2;
GradientPaint gradient = new GradientPaint(x, y, Color.BLUE, x + size, y, Color.WHITE);
g2.setPaint(gradient);
g2.fill(new Rectangle2D.Double(x, y, 50, 50));
g2.fill(new Rectangle2D.Double(x, y, size, size));
BasicStroke wideStroke = new BasicStroke(2.0f);
g2.setColor(Color.black);
g2.setStroke(wideStroke);
g2.draw(new Rectangle2D.Double(x, y, 50, 50));
g2.draw(new Rectangle2D.Double(x, y, size, size));
}
}
Expand Up @@ -23,8 +23,10 @@
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.GeneralPath;

import javax.swing.Icon;
import javax.swing.ImageIcon;

import org.jboss.weld.osgi.examples.paint.api.Shape;

public class Triangle implements Shape {
Expand All @@ -47,14 +49,15 @@ public Icon getIcon() {

@Override
public void draw(Graphics2D g2, Point p) {
int x = p.x - 25;
int y = p.y - 25;
GradientPaint gradient = new GradientPaint(x, y, Color.GREEN, x + 50, y, Color.WHITE);
final int size = 50;
int x = p.x - size / 2;
int y = p.y - size / 2;
GradientPaint gradient = new GradientPaint(x, y, Color.GREEN, x + size, y, Color.WHITE);
g2.setPaint(gradient);
int[] xcoords = {x + 25, x, x + 50};
int[] ycoords = {y, y + 50, y + 50};
int[] xcoords = { x + size / 2, x, x + size };
int[] ycoords = { y, y + size, y + size };
GeneralPath polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xcoords.length);
polygon.moveTo(x + 25, y);
polygon.moveTo(x + size / 2, y);
for (int i = 0; i < xcoords.length; i++) {
polygon.lineTo(xcoords[i], ycoords[i]);
}
Expand Down
Expand Up @@ -3,6 +3,7 @@
import javax.enterprise.event.Observes;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;

import org.jboss.weld.environment.osgi.api.Service;
import org.jboss.weld.environment.osgi.api.annotation.OSGiService;
import org.jboss.weld.environment.osgi.api.events.BundleContainerEvents;
Expand All @@ -11,6 +12,9 @@

public class App {

private static final String LANGUAGE_VALUE_GERMAN = "(language.value=GERMAN)";
private static final String LANGUAGE_VALUE_FRENCH = "(language.value=FRENCH)";

@Inject
@OSGiService
HelloWorld helloWorld;
Expand Down Expand Up @@ -50,8 +54,8 @@ public class App {
public void onStartup(@Observes BundleContainerEvents.BundleContainerInitialized event) {
helloWorld2 = helloWorldService.get();
helloWorldEnglish2 = helloWorldServiceEnglish.select(new LanguageAnnotationEnglish()).get();
helloWorldFrench2 = helloWorldServiceFrench.select("(language.value=FRENCH)").get();
helloWorldGerman2 = helloWorldServiceGerman.select("(language.value=GERMAN)").get();
helloWorldFrench2 = helloWorldServiceFrench.select(LANGUAGE_VALUE_FRENCH).get();
helloWorldGerman2 = helloWorldServiceGerman.select(LANGUAGE_VALUE_GERMAN).get();

helloWorld.sayHello();
helloWorld2.sayHello();
Expand All @@ -70,8 +74,8 @@ public void onStartup(@Observes BundleContainerEvents.BundleContainerInitialized
public void onShutdown(@Observes BundleContainerEvents.BundleContainerShutdown event) {
helloWorld2 = helloWorldService.get();
helloWorldEnglish2 = helloWorldServiceEnglish.select(new LanguageAnnotationEnglish()).get();
helloWorldFrench2 = helloWorldServiceFrench.select("(language.value=FRENCH)").get();
helloWorldGerman2 = helloWorldServiceGerman.select("(language.value=GERMAN)").get();
helloWorldFrench2 = helloWorldServiceFrench.select(LANGUAGE_VALUE_FRENCH).get();
helloWorldGerman2 = helloWorldServiceGerman.select(LANGUAGE_VALUE_GERMAN).get();

helloWorld.sayGoodbye();
helloWorld2.sayGoodbye();
Expand Down
@@ -1,18 +1,21 @@
package org.jboss.weld.osgi.examples.userdoc.talkative.dick;

import org.osgi.framework.Bundle;

import javax.enterprise.event.Event;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

import org.jboss.weld.environment.osgi.api.annotation.Sent;
import org.jboss.weld.environment.osgi.api.annotation.Specification;
import org.jboss.weld.environment.osgi.api.events.BundleContainerEvents;
import org.jboss.weld.environment.osgi.api.events.BundleEvents;
import org.jboss.weld.environment.osgi.api.events.InterBundleEvent;
import org.osgi.framework.Bundle;

public class App {

private static final int NAME_BEGIN_INDEX = 21;
private static final String NAME = "dick";

@Inject
private Event<InterBundleEvent> communication;

Expand All @@ -27,15 +30,15 @@ public void onShutdown(@Observes BundleContainerEvents.BundleContainerShutdown e
}

public void greetNewcomer(@Observes BundleEvents.BundleStarted event) {
String name = event.getSymbolicName().substring(21, event.getSymbolicName().length());
if (!name.equals("dick")) {
String name = event.getSymbolicName().substring(NAME_BEGIN_INDEX, event.getSymbolicName().length());
if (!name.equals(NAME)) {
System.out.println("Dick: Welcome " + name +'!');
}
}

public void sayGoodbyeToLeaver(@Observes BundleEvents.BundleStopped event) {
String name = event.getSymbolicName().substring(21, event.getSymbolicName().length());
if (!name.equals("dick")) {
String name = event.getSymbolicName().substring(NAME_BEGIN_INDEX, event.getSymbolicName().length());
if (!name.equals(NAME)) {
System.out.println("Dick: Goodbye " + name +'!');
}
}
Expand All @@ -54,14 +57,15 @@ private class AskThread extends Thread {
}

public void run() {
final int waitTime = 5000;
while(true) {
try {
sleep(5000);
sleep(waitTime);
} catch (InterruptedException e) {
}
if(bundle.getState() == Bundle.ACTIVE) {
System.out.println("Dick: is there still someone here ?");
communication.fire(new InterBundleEvent("dick"));
communication.fire(new InterBundleEvent(NAME));
} else {
break;
}
Expand Down
@@ -1,18 +1,21 @@
package org.jboss.weld.osgi.examples.userdoc.talkative.harry;

import org.osgi.framework.Bundle;

import javax.enterprise.event.Event;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

import org.jboss.weld.environment.osgi.api.annotation.Sent;
import org.jboss.weld.environment.osgi.api.annotation.Specification;
import org.jboss.weld.environment.osgi.api.events.BundleContainerEvents;
import org.jboss.weld.environment.osgi.api.events.BundleEvents;
import org.jboss.weld.environment.osgi.api.events.InterBundleEvent;
import org.osgi.framework.Bundle;

public class App {

private static final int NAME_BEGIN_INDEX = 21;
private static final String NAME = "harry";

@Inject
private Event<InterBundleEvent> communication;

Expand All @@ -27,15 +30,15 @@ public void onShutdown(@Observes BundleContainerEvents.BundleContainerShutdown e
}

public void greetNewcomer(@Observes BundleEvents.BundleStarted event) {
String name = event.getSymbolicName().substring(21, event.getSymbolicName().length());
if (!name.equals("harry")) {
String name = event.getSymbolicName().substring(NAME_BEGIN_INDEX, event.getSymbolicName().length());
if (!name.equals(NAME)) {
System.out.println("Harry: Welcome " + name + '!');
}
}

public void sayGoodbyeToLeaver(@Observes BundleEvents.BundleStopped event) {
String name = event.getSymbolicName().substring(21, event.getSymbolicName().length());
if (!name.equals("harry")) {
String name = event.getSymbolicName().substring(NAME_BEGIN_INDEX, event.getSymbolicName().length());
if (!name.equals(NAME)) {
System.out.println("Harry: Goodbye " + name + '!');
}
}
Expand All @@ -54,14 +57,15 @@ private class AskThread extends Thread {
}

public void run() {
final int waitTime = 5000;
while(true) {
try {
sleep(5000);
sleep(waitTime);
} catch (InterruptedException e) {
}
if(bundle.getState() == Bundle.ACTIVE) {
System.out.println("Harry: is there still someone here ?");
communication.fire(new InterBundleEvent("harry"));
communication.fire(new InterBundleEvent(NAME));
} else {
break;
}
Expand Down
@@ -1,18 +1,21 @@
package org.jboss.weld.osgi.examples.userdoc.talkative.tom;

import org.osgi.framework.Bundle;

import javax.enterprise.event.Event;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

import org.jboss.weld.environment.osgi.api.annotation.Sent;
import org.jboss.weld.environment.osgi.api.annotation.Specification;
import org.jboss.weld.environment.osgi.api.events.BundleContainerEvents;
import org.jboss.weld.environment.osgi.api.events.BundleEvents;
import org.jboss.weld.environment.osgi.api.events.InterBundleEvent;
import org.osgi.framework.Bundle;

public class App {

private static final int NAME_BEGIN_INDEX = 21;
private static final String NAME = "tom";

@Inject
private Event<InterBundleEvent> communication;

Expand All @@ -27,15 +30,15 @@ public void onShutdown(@Observes BundleContainerEvents.BundleContainerShutdown e
}

public void greetNewcomer(@Observes BundleEvents.BundleStarted event) {
String name = event.getSymbolicName().substring(21, event.getSymbolicName().length());
if (!name.equals("tom")) {
String name = event.getSymbolicName().substring(NAME_BEGIN_INDEX, event.getSymbolicName().length());
if (!name.equals(NAME)) {
System.out.println("Tom: Welcome " + name +'!');
}
}

public void sayGoodbyeToLeaver(@Observes BundleEvents.BundleStopped event) {
String name = event.getSymbolicName().substring(21, event.getSymbolicName().length());
if (!name.equals("tom")) {
String name = event.getSymbolicName().substring(NAME_BEGIN_INDEX, event.getSymbolicName().length());
if (!name.equals(NAME)) {
System.out.println("Tom: Goodbye " + name +'!');
}
}
Expand All @@ -54,14 +57,15 @@ private class AskThread extends Thread {
}

public void run() {
final int waitTime = 5000;
while(true) {
try {
sleep(5000);
sleep(waitTime);
} catch (InterruptedException e) {
}
if(bundle.getState() == Bundle.ACTIVE) {
System.out.println("Tom: is there still someone here ?");
communication.fire(new InterBundleEvent("tom"));
communication.fire(new InterBundleEvent(NAME));
} else {
break;
}
Expand Down

0 comments on commit 812bef6

Please sign in to comment.