Changeset 10599 in josm for trunk/src/org
- Timestamp:
- 2016-07-23T02:08:50+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r10552 r10599 318 318 * 319 319 * @since 8954 320 */ 321 public abstract static class Strategy { 320 * @since 10599 (functional interface) 321 */ 322 @FunctionalInterface 323 public interface Strategy { 322 324 323 325 /** … … 327 329 * @return the way to keep 328 330 */ 329 public abstractWay determineWayToKeep(Iterable<Way> wayChunks);331 Way determineWayToKeep(Iterable<Way> wayChunks); 330 332 331 333 /** … … 333 335 * @return strategy which selects the way chunk with the highest node count to keep 334 336 */ 335 public static Strategy keepLongestChunk() { 336 return new Strategy() { 337 @Override 338 public Way determineWayToKeep(Iterable<Way> wayChunks) { 337 static Strategy keepLongestChunk() { 338 return wayChunks -> { 339 339 Way wayToKeep = null; 340 340 for (Way i : wayChunks) { … … 344 344 } 345 345 return wayToKeep; 346 } 347 }; 346 }; 348 347 } 349 348 … … 352 351 * @return strategy which selects the first way chunk 353 352 */ 354 public static Strategy keepFirstChunk() { 355 return new Strategy() { 356 @Override 357 public Way determineWayToKeep(Iterable<Way> wayChunks) { 358 return wayChunks.iterator().next(); 359 } 360 }; 353 static Strategy keepFirstChunk() { 354 return wayChunks -> wayChunks.iterator().next(); 361 355 } 362 356 } -
trunk/src/org/openstreetmap/josm/command/Command.java
r10467 r10599 37 37 * 38 38 * @author imi 39 * @since 21 (creation) 40 * @since 10599 (signature) 39 41 */ 40 public abstract class Command extends PseudoCommand {42 public abstract class Command implements PseudoCommand { 41 43 42 44 private static final class CloneVisitor extends AbstractVisitor { -
trunk/src/org/openstreetmap/josm/command/PseudoCommand.java
r8447 r10599 12 12 * as subcommand of real commands but it is just an empty shell and can not be 13 13 * executed or undone. 14 * @since 3262 (creation) 15 * @since 10599 (functional interface) 14 16 */ 15 public abstract classPseudoCommand {17 public interface PseudoCommand { 16 18 17 19 /** … … 19 21 * @return description text representing this command 20 22 */ 21 public abstractString getDescriptionText();23 String getDescriptionText(); 22 24 23 25 /** … … 25 27 * @return descriptive icon of this command 26 28 */ 27 publicIcon getDescriptionIcon() {29 default Icon getDescriptionIcon() { 28 30 return null; 29 31 } … … 33 35 * @return primitives that take part in this command 34 36 */ 35 public abstractCollection<? extends OsmPrimitive> getParticipatingPrimitives();37 Collection<? extends OsmPrimitive> getParticipatingPrimitives(); 36 38 37 39 /** … … 40 42 * @return the subcommands, null if there are no child commands 41 43 */ 42 publicCollection<PseudoCommand> getChildren() {44 default Collection<PseudoCommand> getChildren() { 43 45 return null; 44 46 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r10469 r10599 130 130 * Represents a fix to a validation test. The fixing {@link Command} can be obtained by {@link #createCommand(OsmPrimitive, Selector)}. 131 131 */ 132 abstract static class FixCommand { 132 @FunctionalInterface 133 interface FixCommand { 133 134 /** 134 135 * Creates the fixing {@link Command} for the given primitive. The {@code matchingSelector} is used to evaluate placeholders … … 138 139 * @return fix command 139 140 */ 140 abstractCommand createCommand(final OsmPrimitive p, final Selector matchingSelector);141 142 privatestatic void checkObject(final Object obj) {141 Command createCommand(final OsmPrimitive p, final Selector matchingSelector); 142 143 static void checkObject(final Object obj) { 143 144 CheckParameterUtil.ensureThat(obj instanceof Expression || obj instanceof String, 144 145 "instance of Exception or String expected, but got " + obj); … … 152 153 * @return result string 153 154 */ 154 privatestatic String evaluateObject(final Object obj, final OsmPrimitive p, final Selector matchingSelector) {155 static String evaluateObject(final Object obj, final OsmPrimitive p, final Selector matchingSelector) { 155 156 final String s; 156 157 if (obj instanceof Expression) { … … 173 174 return new FixCommand() { 174 175 @Override 175 Command createCommand(OsmPrimitive p, Selector matchingSelector) { 176 public Command createCommand(OsmPrimitive p, Selector matchingSelector) { 176 177 final Tag tag = Tag.ofString(evaluateObject(obj, p, matchingSelector)); 177 178 return new ChangePropertyCommand(p, tag.getKey(), tag.getValue()); … … 194 195 return new FixCommand() { 195 196 @Override 196 Command createCommand(OsmPrimitive p, Selector matchingSelector) { 197 public Command createCommand(OsmPrimitive p, Selector matchingSelector) { 197 198 final String key = evaluateObject(obj, p, matchingSelector); 198 199 return new ChangePropertyCommand(p, key, ""); … … 215 216 return new FixCommand() { 216 217 @Override 217 Command createCommand(OsmPrimitive p, Selector matchingSelector) { 218 public Command createCommand(OsmPrimitive p, Selector matchingSelector) { 218 219 return new ChangePropertyKeyCommand(p, 219 220 TagCheck.insertArguments(matchingSelector, oldKey, p), -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java
r10589 r10599 30 30 import org.openstreetmap.josm.tools.Utils; 31 31 32 public abstract classCondition {33 34 public abstractboolean applies(Environment e);35 36 publicstatic Condition createKeyValueCondition(String k, String v, Op op, Context context, boolean considerValAsKey) {32 public interface Condition { 33 34 boolean applies(Environment e); 35 36 static Condition createKeyValueCondition(String k, String v, Op op, Context context, boolean considerValAsKey) { 37 37 switch (context) { 38 38 case PRIMITIVE: … … 57 57 } 58 58 59 publicstatic Condition createRegexpKeyRegexpValueCondition(String k, String v, Op op) {59 static Condition createRegexpKeyRegexpValueCondition(String k, String v, Op op) { 60 60 return new RegexpKeyValueRegexpCondition(k, v, op); 61 61 } 62 62 63 publicstatic Condition createKeyCondition(String k, boolean not, KeyMatchType matchType, Context context) {63 static Condition createKeyCondition(String k, boolean not, KeyMatchType matchType, Context context) { 64 64 switch (context) { 65 65 case PRIMITIVE: … … 77 77 } 78 78 79 publicstatic PseudoClassCondition createPseudoClassCondition(String id, boolean not, Context context) {79 static PseudoClassCondition createPseudoClassCondition(String id, boolean not, Context context) { 80 80 return PseudoClassCondition.createPseudoClassCondition(id, not, context); 81 81 } 82 82 83 publicstatic ClassCondition createClassCondition(String id, boolean not, Context context) {83 static ClassCondition createClassCondition(String id, boolean not, Context context) { 84 84 return new ClassCondition(id, not); 85 85 } 86 86 87 publicstatic ExpressionCondition createExpressionCondition(Expression e, Context context) {87 static ExpressionCondition createExpressionCondition(Expression e, Context context) { 88 88 return new ExpressionCondition(e); 89 89 } … … 92 92 * This is the operation that {@link KeyValueCondition} uses to match. 93 93 */ 94 publicenum Op {94 enum Op { 95 95 /** The value equals the given reference. */ 96 96 EQ, … … 183 183 * Context, where the condition applies. 184 184 */ 185 publicenum Context {185 enum Context { 186 186 /** 187 187 * normal primitive selector, e.g. way[highway=residential] … … 200 200 * Extra class for performance reasons. 201 201 */ 202 public staticclass SimpleKeyValueConditionextends Condition {202 class SimpleKeyValueCondition implements Condition { 203 203 /** 204 204 * The key to search for. … … 240 240 * 241 241 */ 242 public staticclass KeyValueConditionextends Condition {242 class KeyValueCondition implements Condition { 243 243 /** 244 244 * The key to search for. … … 288 288 } 289 289 290 public staticclass KeyValueRegexpCondition extends KeyValueCondition {290 class KeyValueRegexpCondition extends KeyValueCondition { 291 291 292 292 public final Pattern pattern; … … 317 317 } 318 318 319 public staticclass RegexpKeyValueRegexpCondition extends KeyValueRegexpCondition {319 class RegexpKeyValueRegexpCondition extends KeyValueRegexpCondition { 320 320 321 321 public final Pattern keyPattern; … … 337 337 } 338 338 339 public staticclass RoleConditionextends Condition {339 class RoleCondition implements Condition { 340 340 public final String role; 341 341 public final Op op; … … 354 354 } 355 355 356 public staticclass IndexConditionextends Condition {356 class IndexCondition implements Condition { 357 357 public final String index; 358 358 public final Op op; … … 377 377 * This defines how {@link KeyCondition} matches a given key. 378 378 */ 379 publicenum KeyMatchType {379 enum KeyMatchType { 380 380 /** 381 381 * The key needs to be equal to the given label. … … 417 417 * </pre> 418 418 */ 419 public staticclass KeyConditionextends Condition {419 class KeyCondition implements Condition { 420 420 421 421 /** … … 499 499 } 500 500 501 public staticclass ClassConditionextends Condition {501 class ClassCondition implements Condition { 502 502 503 503 public final String id; … … 524 524 * are written in lower case with dashes between words. 525 525 */ 526 static class PseudoClasses { 526 final class PseudoClasses { 527 528 private PseudoClasses() { 529 // Hide default constructor for utilities classes 530 } 527 531 528 532 /** … … 687 691 } 688 692 689 public staticclass PseudoClassConditionextends Condition {693 class PseudoClassCondition implements Condition { 690 694 691 695 public final Method method; … … 736 740 } 737 741 738 public staticclass OpenEndPseudoClassCondition extends PseudoClassCondition {742 class OpenEndPseudoClassCondition extends PseudoClassCondition { 739 743 public OpenEndPseudoClassCondition(boolean not) { 740 744 super(null, not); … … 747 751 } 748 752 749 public staticclass ExpressionConditionextends Condition {753 class ExpressionCondition implements Condition { 750 754 751 755 private final Expression e; -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LabelCompositionStrategy.java
r10300 r10599 34 34 * options <tt>mappaint.nameOrder</tt> and <tt>mappaint.nameComplementOrder</tt>.</li> 35 35 * </ul> 36 * 36 * @since 3987 (creation) 37 * @since 10599 (functional interface) 37 38 */ 38 public abstract class LabelCompositionStrategy { 39 @FunctionalInterface 40 public interface LabelCompositionStrategy { 39 41 40 42 /** … … 46 48 * if no suitable value could be composed 47 49 */ 48 public abstractString compose(OsmPrimitive primitive);49 50 public staticclass StaticLabelCompositionStrategyextends LabelCompositionStrategy {50 String compose(OsmPrimitive primitive); 51 52 class StaticLabelCompositionStrategy implements LabelCompositionStrategy { 51 53 private final String defaultLabel; 52 54 … … 83 85 } 84 86 85 public staticclass TagLookupCompositionStrategyextends LabelCompositionStrategy {87 class TagLookupCompositionStrategy implements LabelCompositionStrategy { 86 88 87 89 private final String defaultLabelTag; … … 127 129 } 128 130 129 public static class DeriveLabelFromNameTagsCompositionStrategy 130 extends LabelCompositionStrategy implements PreferenceChangedListener { 131 class DeriveLabelFromNameTagsCompositionStrategy implements LabelCompositionStrategy, PreferenceChangedListener { 131 132 132 133 /** -
trunk/src/org/openstreetmap/josm/gui/util/RotationAngle.java
r10228 r10599 12 12 13 13 /** 14 * Determines how an icon is to be rotated depending on the primitive to displayed. 14 * Determines how an icon is to be rotated depending on the primitive to be displayed. 15 * @since 8199 (creation) 16 * @since 10599 (functional interface) 15 17 */ 16 public abstract class RotationAngle { 18 @FunctionalInterface 19 public interface RotationAngle { 17 20 18 21 /** 19 * Calculates the rotation angle depending on the primitive to displayed. 22 * Calculates the rotation angle depending on the primitive to be displayed. 20 23 * @param p primitive 21 24 * @return rotation angle 22 25 */ 23 public abstractdouble getRotationAngle(OsmPrimitive p);26 double getRotationAngle(OsmPrimitive p); 24 27 25 28 /** … … 28 31 * @return rotation angle 29 32 */ 30 publicstatic RotationAngle buildStaticRotation(final double angle) {33 static RotationAngle buildStaticRotation(final double angle) { 31 34 return new RotationAngle() { 32 35 @Override … … 47 50 * @return rotation angle 48 51 */ 49 publicstatic RotationAngle buildStaticRotation(final String string) {52 static RotationAngle buildStaticRotation(final String string) { 50 53 try { 51 54 return buildStaticRotation(parseCardinalRotation(string)); … … 63 66 * @return the angle in radians 64 67 */ 65 publicstatic double parseCardinalRotation(final String cardinal) {68 static double parseCardinalRotation(final String cardinal) { 66 69 switch (cardinal.toLowerCase(Locale.ENGLISH)) { 67 70 case "n": … … 98 101 * @return rotation angle 99 102 */ 100 publicstatic RotationAngle buildWayDirectionRotation() {103 static RotationAngle buildWayDirectionRotation() { 101 104 return new RotationAngle() { 102 105 @Override
Note:
See TracChangeset
for help on using the changeset viewer.