Ignore:
Timestamp:
2017-09-07T23:41:42+02:00 (9 years ago)
Author:
bastiK
Message:

see #15229 - remove dependency of NTV2GridShiftFileWrapper on Main.platform

  • PlatformHook bundles all application-wide platform dependent code, which is

convenient, but problematic for separating modules

  • introduces lightweight tools.Platform for adding platform dependent code more locally
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/PlatformHook.java

    r12748 r12776  
    2020
    2121import org.openstreetmap.josm.Main;
     22import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper;
    2223import org.openstreetmap.josm.io.CertificateAmendment.CertAmend;
    2324import org.openstreetmap.josm.tools.date.DateUtils;
     
    2930 */
    3031public interface PlatformHook {
     32
     33    /**
     34     * Visitor to construct a PlatformHook from a given {@link Platform} object.
     35     */
     36    public static final PlatformVisitor<PlatformHook> CONSTRUCT_FROM_PLATFORM = new PlatformVisitor<PlatformHook>() {
     37        @Override
     38        public PlatformHook visitUnixoid() {
     39            return new PlatformHookUnixoid();
     40        }
     41
     42        @Override
     43        public PlatformHook visitWindows() {
     44            return new PlatformHookWindows();
     45        }
     46
     47        @Override
     48        public PlatformHook visitOsx() {
     49            return new PlatformHookUnixoid();
     50        }
     51    };
     52
     53    /**
     54     * Get the platform corresponding to this platform hook.
     55     * @return the platform corresponding to this platform hook
     56     */
     57    Platform getPlatform();
    3158
    3259    /**
     
    231258     * @since 11642
    232259     */
    233     List<File> getDefaultProj4NadshiftDirectories();
     260    default List<File> getDefaultProj4NadshiftDirectories() {
     261        return getPlatform().accept(NTV2GridShiftFileWrapper.DEFAULT_PROJ4_NTV2_SHIFT_DIRS);
     262    }
    234263
    235264    /**
Note: See TracChangeset for help on using the changeset viewer.