repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
IAmContent/public
public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbTopologyExplorer.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java // public class Usb { // // public static EasyUsbDevice device(short vendorId, short productId) { // return first(devices(vendorId, productId)); // } // // public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { // return first(devices(shouldIncludeDevice)); // } // // public static List<EasyUsbDevice> devices(short vendorId, short productId) { // return devices(deviceHasVendorIdAndProductId(vendorId, productId)); // } // // public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) { // final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice); // deviceFinder.exploreRootUsbHub(); // return deviceFinder.getDevices(); // } // // public static UsbHub rootUsbHub() { // try { // return usbServices().getRootUsbHub(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // public static UsbServices usbServices() { // try { // return UsbHostManager.getUsbServices(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // private static <T> T first(List<T> l) { // try { // return l.get(0); // } catch (IndexOutOfBoundsException e) { // throw new UsbRuntimeException("No suitable USB Device found."); // } // } // // private Usb() { // } // }
import com.iamcontent.io.usb.Usb; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHub;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb.topology; /** * An abstract class that recursively explores the USB devices in a USB topology, starting at * a specific device, or the root USB hub. * @author Greg Elderfield */ public abstract class UsbTopologyExplorer { private final Predicate<UsbDevice> shouldVisit; /** * Creates an instance. * @param shouldVisit Indicates whether the {@link #visit(UsbDevice)} method should be invoked for a given device. */ public UsbTopologyExplorer(Predicate<UsbDevice> shouldVisit) { this.shouldVisit = shouldVisit; } /** * Explore the USB topology, starting at the root USB hub. */ public void exploreRootUsbHub() {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java // public class Usb { // // public static EasyUsbDevice device(short vendorId, short productId) { // return first(devices(vendorId, productId)); // } // // public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { // return first(devices(shouldIncludeDevice)); // } // // public static List<EasyUsbDevice> devices(short vendorId, short productId) { // return devices(deviceHasVendorIdAndProductId(vendorId, productId)); // } // // public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) { // final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice); // deviceFinder.exploreRootUsbHub(); // return deviceFinder.getDevices(); // } // // public static UsbHub rootUsbHub() { // try { // return usbServices().getRootUsbHub(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // public static UsbServices usbServices() { // try { // return UsbHostManager.getUsbServices(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // private static <T> T first(List<T> l) { // try { // return l.get(0); // } catch (IndexOutOfBoundsException e) { // throw new UsbRuntimeException("No suitable USB Device found."); // } // } // // private Usb() { // } // } // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbTopologyExplorer.java import com.iamcontent.io.usb.Usb; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHub; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb.topology; /** * An abstract class that recursively explores the USB devices in a USB topology, starting at * a specific device, or the root USB hub. * @author Greg Elderfield */ public abstract class UsbTopologyExplorer { private final Predicate<UsbDevice> shouldVisit; /** * Creates an instance. * @param shouldVisit Indicates whether the {@link #visit(UsbDevice)} method should be invoked for a given device. */ public UsbTopologyExplorer(Predicate<UsbDevice> shouldVisit) { this.shouldVisit = shouldVisit; } /** * Explore the USB topology, starting at the root USB hub. */ public void exploreRootUsbHub() {
explore(Usb.rootUsbHub());
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSourceCalibration.java // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration(ServoCalibration calibration) { // return new DefaultingServoSourceCalibration<C>(calibration); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServoSource.java // public class CalibratedServoSource<C> extends Delegator<ServoSource<C>> implements ServoSource<C> { // // protected final ServoSourceCalibration<C> calibration; // // public CalibratedServoSource(ServoSource<C> target, ServoSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public Servo forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RawServo.java // public class RawServo<C> implements Servo { // // protected final ServoController<C> controller; // protected final C channelId; // // public RawServo(ServoController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // // @Override // public MutableDouble speed() { // return controller.speed(channelId); // } // // @Override // public MutableDouble acceleration() { // return controller.acceleration(channelId); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RemappedServoSource.java // public class RemappedServoSource<NewChannelId, DelegateChannelId> extends Delegator<ServoSource<DelegateChannelId>> implements ServoSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedServoSource(ServoSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public Servo forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // }
import static com.iamcontent.device.servo.ServoSourceCalibration.servoSourceCalibration; import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.servo.impl.CalibratedServoSource; import com.iamcontent.device.servo.impl.RawServo; import com.iamcontent.device.servo.impl.RemappedServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo; /** * Represents a source of {@link Servo}s. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public interface ServoSource<C> extends PerChannelSource<C, Servo> { /** * Returns a ServoSource that has new channel ids, as defined by the given function. */ default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) {
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSourceCalibration.java // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration(ServoCalibration calibration) { // return new DefaultingServoSourceCalibration<C>(calibration); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServoSource.java // public class CalibratedServoSource<C> extends Delegator<ServoSource<C>> implements ServoSource<C> { // // protected final ServoSourceCalibration<C> calibration; // // public CalibratedServoSource(ServoSource<C> target, ServoSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public Servo forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RawServo.java // public class RawServo<C> implements Servo { // // protected final ServoController<C> controller; // protected final C channelId; // // public RawServo(ServoController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // // @Override // public MutableDouble speed() { // return controller.speed(channelId); // } // // @Override // public MutableDouble acceleration() { // return controller.acceleration(channelId); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RemappedServoSource.java // public class RemappedServoSource<NewChannelId, DelegateChannelId> extends Delegator<ServoSource<DelegateChannelId>> implements ServoSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedServoSource(ServoSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public Servo forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java import static com.iamcontent.device.servo.ServoSourceCalibration.servoSourceCalibration; import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.servo.impl.CalibratedServoSource; import com.iamcontent.device.servo.impl.RawServo; import com.iamcontent.device.servo.impl.RemappedServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo; /** * Represents a source of {@link Servo}s. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public interface ServoSource<C> extends PerChannelSource<C, Servo> { /** * Returns a ServoSource that has new channel ids, as defined by the given function. */ default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) {
return new RemappedServoSource<NewServoId, C>(this, remapping);
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSourceCalibration.java // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration(ServoCalibration calibration) { // return new DefaultingServoSourceCalibration<C>(calibration); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServoSource.java // public class CalibratedServoSource<C> extends Delegator<ServoSource<C>> implements ServoSource<C> { // // protected final ServoSourceCalibration<C> calibration; // // public CalibratedServoSource(ServoSource<C> target, ServoSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public Servo forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RawServo.java // public class RawServo<C> implements Servo { // // protected final ServoController<C> controller; // protected final C channelId; // // public RawServo(ServoController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // // @Override // public MutableDouble speed() { // return controller.speed(channelId); // } // // @Override // public MutableDouble acceleration() { // return controller.acceleration(channelId); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RemappedServoSource.java // public class RemappedServoSource<NewChannelId, DelegateChannelId> extends Delegator<ServoSource<DelegateChannelId>> implements ServoSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedServoSource(ServoSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public Servo forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // }
import static com.iamcontent.device.servo.ServoSourceCalibration.servoSourceCalibration; import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.servo.impl.CalibratedServoSource; import com.iamcontent.device.servo.impl.RawServo; import com.iamcontent.device.servo.impl.RemappedServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo; /** * Represents a source of {@link Servo}s. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public interface ServoSource<C> extends PerChannelSource<C, Servo> { /** * Returns a ServoSource that has new channel ids, as defined by the given function. */ default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { return new RemappedServoSource<NewServoId, C>(this, remapping); } /** * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. */ default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) {
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSourceCalibration.java // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration(ServoCalibration calibration) { // return new DefaultingServoSourceCalibration<C>(calibration); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServoSource.java // public class CalibratedServoSource<C> extends Delegator<ServoSource<C>> implements ServoSource<C> { // // protected final ServoSourceCalibration<C> calibration; // // public CalibratedServoSource(ServoSource<C> target, ServoSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public Servo forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RawServo.java // public class RawServo<C> implements Servo { // // protected final ServoController<C> controller; // protected final C channelId; // // public RawServo(ServoController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // // @Override // public MutableDouble speed() { // return controller.speed(channelId); // } // // @Override // public MutableDouble acceleration() { // return controller.acceleration(channelId); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RemappedServoSource.java // public class RemappedServoSource<NewChannelId, DelegateChannelId> extends Delegator<ServoSource<DelegateChannelId>> implements ServoSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedServoSource(ServoSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public Servo forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java import static com.iamcontent.device.servo.ServoSourceCalibration.servoSourceCalibration; import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.servo.impl.CalibratedServoSource; import com.iamcontent.device.servo.impl.RawServo; import com.iamcontent.device.servo.impl.RemappedServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo; /** * Represents a source of {@link Servo}s. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public interface ServoSource<C> extends PerChannelSource<C, Servo> { /** * Returns a ServoSource that has new channel ids, as defined by the given function. */ default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { return new RemappedServoSource<NewServoId, C>(this, remapping); } /** * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. */ default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) {
return new CalibratedServoSource<C>(this, calibration);
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSourceCalibration.java // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration(ServoCalibration calibration) { // return new DefaultingServoSourceCalibration<C>(calibration); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServoSource.java // public class CalibratedServoSource<C> extends Delegator<ServoSource<C>> implements ServoSource<C> { // // protected final ServoSourceCalibration<C> calibration; // // public CalibratedServoSource(ServoSource<C> target, ServoSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public Servo forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RawServo.java // public class RawServo<C> implements Servo { // // protected final ServoController<C> controller; // protected final C channelId; // // public RawServo(ServoController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // // @Override // public MutableDouble speed() { // return controller.speed(channelId); // } // // @Override // public MutableDouble acceleration() { // return controller.acceleration(channelId); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RemappedServoSource.java // public class RemappedServoSource<NewChannelId, DelegateChannelId> extends Delegator<ServoSource<DelegateChannelId>> implements ServoSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedServoSource(ServoSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public Servo forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // }
import static com.iamcontent.device.servo.ServoSourceCalibration.servoSourceCalibration; import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.servo.impl.CalibratedServoSource; import com.iamcontent.device.servo.impl.RawServo; import com.iamcontent.device.servo.impl.RemappedServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo; /** * Represents a source of {@link Servo}s. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public interface ServoSource<C> extends PerChannelSource<C, Servo> { /** * Returns a ServoSource that has new channel ids, as defined by the given function. */ default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { return new RemappedServoSource<NewServoId, C>(this, remapping); } /** * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. */ default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { return new CalibratedServoSource<C>(this, calibration); } /** * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. */ default ServoSource<C> calibrated(ServoCalibration calibration) {
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSourceCalibration.java // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration(ServoCalibration calibration) { // return new DefaultingServoSourceCalibration<C>(calibration); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServoSource.java // public class CalibratedServoSource<C> extends Delegator<ServoSource<C>> implements ServoSource<C> { // // protected final ServoSourceCalibration<C> calibration; // // public CalibratedServoSource(ServoSource<C> target, ServoSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public Servo forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RawServo.java // public class RawServo<C> implements Servo { // // protected final ServoController<C> controller; // protected final C channelId; // // public RawServo(ServoController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // // @Override // public MutableDouble speed() { // return controller.speed(channelId); // } // // @Override // public MutableDouble acceleration() { // return controller.acceleration(channelId); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RemappedServoSource.java // public class RemappedServoSource<NewChannelId, DelegateChannelId> extends Delegator<ServoSource<DelegateChannelId>> implements ServoSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedServoSource(ServoSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public Servo forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java import static com.iamcontent.device.servo.ServoSourceCalibration.servoSourceCalibration; import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.servo.impl.CalibratedServoSource; import com.iamcontent.device.servo.impl.RawServo; import com.iamcontent.device.servo.impl.RemappedServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo; /** * Represents a source of {@link Servo}s. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public interface ServoSource<C> extends PerChannelSource<C, Servo> { /** * Returns a ServoSource that has new channel ids, as defined by the given function. */ default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { return new RemappedServoSource<NewServoId, C>(this, remapping); } /** * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. */ default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { return new CalibratedServoSource<C>(this, calibration); } /** * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. */ default ServoSource<C> calibrated(ServoCalibration calibration) {
return calibrated(servoSourceCalibration(calibration));
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSourceCalibration.java // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration(ServoCalibration calibration) { // return new DefaultingServoSourceCalibration<C>(calibration); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServoSource.java // public class CalibratedServoSource<C> extends Delegator<ServoSource<C>> implements ServoSource<C> { // // protected final ServoSourceCalibration<C> calibration; // // public CalibratedServoSource(ServoSource<C> target, ServoSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public Servo forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RawServo.java // public class RawServo<C> implements Servo { // // protected final ServoController<C> controller; // protected final C channelId; // // public RawServo(ServoController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // // @Override // public MutableDouble speed() { // return controller.speed(channelId); // } // // @Override // public MutableDouble acceleration() { // return controller.acceleration(channelId); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RemappedServoSource.java // public class RemappedServoSource<NewChannelId, DelegateChannelId> extends Delegator<ServoSource<DelegateChannelId>> implements ServoSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedServoSource(ServoSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public Servo forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // }
import static com.iamcontent.device.servo.ServoSourceCalibration.servoSourceCalibration; import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.servo.impl.CalibratedServoSource; import com.iamcontent.device.servo.impl.RawServo; import com.iamcontent.device.servo.impl.RemappedServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo; /** * Represents a source of {@link Servo}s. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public interface ServoSource<C> extends PerChannelSource<C, Servo> { /** * Returns a ServoSource that has new channel ids, as defined by the given function. */ default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { return new RemappedServoSource<NewServoId, C>(this, remapping); } /** * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. */ default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { return new CalibratedServoSource<C>(this, calibration); } /** * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. */ default ServoSource<C> calibrated(ServoCalibration calibration) { return calibrated(servoSourceCalibration(calibration)); } /** * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. */ public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { return new ServoSource<C>() { @Override public Servo forChannel(C channel) {
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSourceCalibration.java // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration(ServoCalibration calibration) { // return new DefaultingServoSourceCalibration<C>(calibration); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServoSource.java // public class CalibratedServoSource<C> extends Delegator<ServoSource<C>> implements ServoSource<C> { // // protected final ServoSourceCalibration<C> calibration; // // public CalibratedServoSource(ServoSource<C> target, ServoSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public Servo forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RawServo.java // public class RawServo<C> implements Servo { // // protected final ServoController<C> controller; // protected final C channelId; // // public RawServo(ServoController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // // @Override // public MutableDouble speed() { // return controller.speed(channelId); // } // // @Override // public MutableDouble acceleration() { // return controller.acceleration(channelId); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RemappedServoSource.java // public class RemappedServoSource<NewChannelId, DelegateChannelId> extends Delegator<ServoSource<DelegateChannelId>> implements ServoSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedServoSource(ServoSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public Servo forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java import static com.iamcontent.device.servo.ServoSourceCalibration.servoSourceCalibration; import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.servo.impl.CalibratedServoSource; import com.iamcontent.device.servo.impl.RawServo; import com.iamcontent.device.servo.impl.RemappedServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo; /** * Represents a source of {@link Servo}s. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public interface ServoSource<C> extends PerChannelSource<C, Servo> { /** * Returns a ServoSource that has new channel ids, as defined by the given function. */ default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { return new RemappedServoSource<NewServoId, C>(this, remapping); } /** * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. */ default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { return new CalibratedServoSource<C>(this, calibration); } /** * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. */ default ServoSource<C> calibrated(ServoCalibration calibration) { return calibrated(servoSourceCalibration(calibration)); } /** * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. */ public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { return new ServoSource<C>() { @Override public Servo forChannel(C channel) {
return new RawServo<C>(controller, channel);
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonova.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // }
import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, iamcontent@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * A specific implementation of Greg Elderfield's Robonova-1. * @author Greg Elderfield */ public class CustomRobonova implements Robonova { @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonova.java import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, iamcontent@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * A specific implementation of Greg Elderfield's Robonova-1. * @author Greg Elderfield */ public class CustomRobonova implements Robonova { @Override
public ServoSource<ServoId> servos() {
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonova.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // }
import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, iamcontent@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * A specific implementation of Greg Elderfield's Robonova-1. * @author Greg Elderfield */ public class CustomRobonova implements Robonova { @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonova.java import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, iamcontent@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * A specific implementation of Greg Elderfield's Robonova-1. * @author Greg Elderfield */ public class CustomRobonova implements Robonova { @Override
public ServoSource<ServoId> servos() {
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonova.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // }
import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, iamcontent@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * A specific implementation of Greg Elderfield's Robonova-1. * @author Greg Elderfield */ public class CustomRobonova implements Robonova { @Override public ServoSource<ServoId> servos() { return CustomRobonovaServos.servoSource(); } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonova.java import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, iamcontent@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * A specific implementation of Greg Elderfield's Robonova-1. * @author Greg Elderfield */ public class CustomRobonova implements Robonova { @Override public ServoSource<ServoId> servos() { return CustomRobonovaServos.servoSource(); } @Override
public AnalogIOSource<ThreeDimension> accelerometer() {
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonova.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // }
import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, iamcontent@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * A specific implementation of Greg Elderfield's Robonova-1. * @author Greg Elderfield */ public class CustomRobonova implements Robonova { @Override public ServoSource<ServoId> servos() { return CustomRobonovaServos.servoSource(); } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonova.java import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, iamcontent@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * A specific implementation of Greg Elderfield's Robonova-1. * @author Greg Elderfield */ public class CustomRobonova implements Robonova { @Override public ServoSource<ServoId> servos() { return CustomRobonovaServos.servoSource(); } @Override
public AnalogIOSource<ThreeDimension> accelerometer() {
IAmContent/public
public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RawAnalogIO.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java // public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIO calibrated(AnalogIOCalibration calibration) { // return new CalibratedAnalogIO(this, calibration); // } // // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOController.java // public interface AnalogIOController<C> { // MutableDouble value(C channel); // }
import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.io.analog.AnalogIO; import com.iamcontent.device.io.analog.AnalogIOController;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog.impl; /** * An {@link AnalogIO} that directly delegates its operations to an {@link AnalogIOController} without altering the * results of the operations. * @author Greg Elderfield * * @param <C> The type used to identify the channel of an {@link AnalogIO}. */ public class RawAnalogIO<C> implements AnalogIO { protected final AnalogIOController<C> controller; protected final C channelId; public RawAnalogIO(AnalogIOController<C> controller, C channelId) { this.controller = controller; this.channelId = channelId; } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java // public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIO calibrated(AnalogIOCalibration calibration) { // return new CalibratedAnalogIO(this, calibration); // } // // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOController.java // public interface AnalogIOController<C> { // MutableDouble value(C channel); // } // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RawAnalogIO.java import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.io.analog.AnalogIO; import com.iamcontent.device.io.analog.AnalogIOController; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog.impl; /** * An {@link AnalogIO} that directly delegates its operations to an {@link AnalogIOController} without altering the * results of the operations. * @author Greg Elderfield * * @param <C> The type used to identify the channel of an {@link AnalogIO}. */ public class RawAnalogIO<C> implements AnalogIO { protected final AnalogIOController<C> controller; protected final C channelId; public RawAnalogIO(AnalogIOController<C> controller, C channelId) { this.controller = controller; this.channelId = channelId; } @Override
public MutableDouble value() {
IAmContent/public
public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/MathUtilsTest.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java // public static int clamp(int i, int min, int max) { // return Math.min(max, Math.max(i, min)); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java // public static double linearConvert(double v, double from1, double from2, double to1, double to2) { // final double fromRange = from2 - from1; // final double toRange = to2 - to1; // final double quotient = (v-from1)/fromRange; // return (quotient * toRange) + to1; // }
import static com.iamcontent.core.math.MathUtils.clamp; import static com.iamcontent.core.math.MathUtils.linearConvert; import static org.junit.Assert.assertEquals; import org.junit.Test;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.core.math; public class MathUtilsTest { private static final double TOLERANCE = 0.000001; @Test public void testClamp_int() { checkIntClamp1to3(1, 0); checkIntClamp1to3(1, 1); checkIntClamp1to3(2, 2); checkIntClamp1to3(3, 3); checkIntClamp1to3(3, 4); } private void checkIntClamp1to3(int expected, int in) {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java // public static int clamp(int i, int min, int max) { // return Math.min(max, Math.max(i, min)); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java // public static double linearConvert(double v, double from1, double from2, double to1, double to2) { // final double fromRange = from2 - from1; // final double toRange = to2 - to1; // final double quotient = (v-from1)/fromRange; // return (quotient * toRange) + to1; // } // Path: public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/MathUtilsTest.java import static com.iamcontent.core.math.MathUtils.clamp; import static com.iamcontent.core.math.MathUtils.linearConvert; import static org.junit.Assert.assertEquals; import org.junit.Test; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.core.math; public class MathUtilsTest { private static final double TOLERANCE = 0.000001; @Test public void testClamp_int() { checkIntClamp1to3(1, 0); checkIntClamp1to3(1, 1); checkIntClamp1to3(2, 2); checkIntClamp1to3(3, 3); checkIntClamp1to3(3, 4); } private void checkIntClamp1to3(int expected, int in) {
assertEquals(expected, clamp(in, 1, 3));
IAmContent/public
public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/MathUtilsTest.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java // public static int clamp(int i, int min, int max) { // return Math.min(max, Math.max(i, min)); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java // public static double linearConvert(double v, double from1, double from2, double to1, double to2) { // final double fromRange = from2 - from1; // final double toRange = to2 - to1; // final double quotient = (v-from1)/fromRange; // return (quotient * toRange) + to1; // }
import static com.iamcontent.core.math.MathUtils.clamp; import static com.iamcontent.core.math.MathUtils.linearConvert; import static org.junit.Assert.assertEquals; import org.junit.Test;
checkIntClamp1to3(3, 4); } private void checkIntClamp1to3(int expected, int in) { assertEquals(expected, clamp(in, 1, 3)); } @Test public void testClamp_double() { checkDoubleClamp1to3(1, 0); checkDoubleClamp1to3(1, 1); checkDoubleClamp1to3(2, 2); checkDoubleClamp1to3(3, 3); checkDoubleClamp1to3(3, 4); } private void checkDoubleClamp1to3(double expected, double in) { assertExactlyEquals(expected, clamp(in, 1.0, 3.0)); } @Test public void testLinearConvert() { checkLinearConvert(10.0, 0.0); checkLinearConvert(20.0, 1.0); checkLinearConvert(25.0, 1.5); checkLinearConvert(30.0, 2.0); checkLinearConvert(40.0, 3.0); } private void checkLinearConvert(double expected, double in) {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java // public static int clamp(int i, int min, int max) { // return Math.min(max, Math.max(i, min)); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java // public static double linearConvert(double v, double from1, double from2, double to1, double to2) { // final double fromRange = from2 - from1; // final double toRange = to2 - to1; // final double quotient = (v-from1)/fromRange; // return (quotient * toRange) + to1; // } // Path: public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/MathUtilsTest.java import static com.iamcontent.core.math.MathUtils.clamp; import static com.iamcontent.core.math.MathUtils.linearConvert; import static org.junit.Assert.assertEquals; import org.junit.Test; checkIntClamp1to3(3, 4); } private void checkIntClamp1to3(int expected, int in) { assertEquals(expected, clamp(in, 1, 3)); } @Test public void testClamp_double() { checkDoubleClamp1to3(1, 0); checkDoubleClamp1to3(1, 1); checkDoubleClamp1to3(2, 2); checkDoubleClamp1to3(3, 3); checkDoubleClamp1to3(3, 4); } private void checkDoubleClamp1to3(double expected, double in) { assertExactlyEquals(expected, clamp(in, 1.0, 3.0)); } @Test public void testLinearConvert() { checkLinearConvert(10.0, 0.0); checkLinearConvert(20.0, 1.0); checkLinearConvert(25.0, 1.5); checkLinearConvert(30.0, 2.0); checkLinearConvert(40.0, 3.0); } private void checkLinearConvert(double expected, double in) {
assertCloseEnough(expected, linearConvert(in, 1.0, 2.0, 20.0, 30.0));
IAmContent/public
public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIO.java // public class CalibratedAnalogIO extends Delegator<AnalogIO> implements AnalogIO { // // private final AnalogIOCalibration calibration; // // public CalibratedAnalogIO(AnalogIO target, AnalogIOCalibration calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public MutableDouble value() { // return delegate().value().calibrated(calibration().value()); // } // // protected AnalogIOCalibration calibration() { // return calibration; // } // }
import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.io.analog.impl.CalibratedAnalogIO;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog; /** * Represents an analog input/output channel. * * @author Greg Elderfield */ public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { /** * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. */ default AnalogIO calibrated(AnalogIOCalibration calibration) {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIO.java // public class CalibratedAnalogIO extends Delegator<AnalogIO> implements AnalogIO { // // private final AnalogIOCalibration calibration; // // public CalibratedAnalogIO(AnalogIO target, AnalogIOCalibration calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public MutableDouble value() { // return delegate().value().calibrated(calibration().value()); // } // // protected AnalogIOCalibration calibration() { // return calibration; // } // } // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.io.analog.impl.CalibratedAnalogIO; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog; /** * Represents an analog input/output channel. * * @author Greg Elderfield */ public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { /** * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. */ default AnalogIO calibrated(AnalogIOCalibration calibration) {
return new CalibratedAnalogIO(this, calibration);
IAmContent/public
public-java/io/iamcontent-io-core/src/test/java/com/iamcontent/io/util/ResourceUtilsTest.java
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.FileNotFoundException; import java.io.IOException; import org.junit.Test; import com.iamcontent.io.IORuntimeException;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.util; public class ResourceUtilsTest { private static final String TEST_RESOURCE = "test-resource.txt";
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/io/iamcontent-io-core/src/test/java/com/iamcontent/io/util/ResourceUtilsTest.java import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.FileNotFoundException; import java.io.IOException; import org.junit.Test; import com.iamcontent.io.IORuntimeException; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.util; public class ResourceUtilsTest { private static final String TEST_RESOURCE = "test-resource.txt";
@Test(expected=IORuntimeException.class)
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/command/SitCommand.java
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/command/ImmutableServoCommand.java // public static <C> ServoCommand<C> immutableCommand(C channel, Double value, Double speed, Double acceleration) { // return new ImmutableServoCommand<C>(channel, value, speed, acceleration); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/command/CompoundServoCommand.java // public abstract class CompoundServoCommand<C> extends ArrayList<ServoCommand<C>> { // // @SafeVarargs // public CompoundServoCommand(ServoCommand<C>... commands) { // addAll(Arrays.asList(commands)); // } // // private static final long serialVersionUID = 1L; // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // }
import static com.iamcontent.device.servo.command.ImmutableServoCommand.immutableCommand; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ANKLE_INVERTER; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ANKLE_PLANTARFLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ELBOW_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_HIP_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_HIP_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_KNEE_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_SHOULDER_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_SHOULDER_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ANKLE_INVERTER; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ANKLE_PLANTARFLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ELBOW_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_HIP_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_HIP_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_KNEE_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_SHOULDER_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_SHOULDER_FLEXOR; import com.iamcontent.device.servo.command.CompoundServoCommand; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId;
package com.iamcontent.robot.robonova1.command; /** * A compound command to put a {@link Robonova} into a sitting position. * @author Greg Elderfield */ public class SitCommand extends CompoundServoCommand<ServoId> { public SitCommand() { super(
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/command/ImmutableServoCommand.java // public static <C> ServoCommand<C> immutableCommand(C channel, Double value, Double speed, Double acceleration) { // return new ImmutableServoCommand<C>(channel, value, speed, acceleration); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/command/CompoundServoCommand.java // public abstract class CompoundServoCommand<C> extends ArrayList<ServoCommand<C>> { // // @SafeVarargs // public CompoundServoCommand(ServoCommand<C>... commands) { // addAll(Arrays.asList(commands)); // } // // private static final long serialVersionUID = 1L; // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/command/SitCommand.java import static com.iamcontent.device.servo.command.ImmutableServoCommand.immutableCommand; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ANKLE_INVERTER; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ANKLE_PLANTARFLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ELBOW_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_HIP_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_HIP_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_KNEE_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_SHOULDER_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_SHOULDER_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ANKLE_INVERTER; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ANKLE_PLANTARFLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ELBOW_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_HIP_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_HIP_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_KNEE_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_SHOULDER_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_SHOULDER_FLEXOR; import com.iamcontent.device.servo.command.CompoundServoCommand; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId; package com.iamcontent.robot.robonova1.command; /** * A compound command to put a {@link Robonova} into a sitting position. * @author Greg Elderfield */ public class SitCommand extends CompoundServoCommand<ServoId> { public SitCommand() { super(
immutableCommand(LEFT_SHOULDER_FLEXOR, 0.5, 1.0, 0.02),
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/command/StandCommand.java
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/command/ImmutableServoCommand.java // public static <C> ServoCommand<C> immutableCommand(C channel, Double value, Double speed, Double acceleration) { // return new ImmutableServoCommand<C>(channel, value, speed, acceleration); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/command/CompoundServoCommand.java // public abstract class CompoundServoCommand<C> extends ArrayList<ServoCommand<C>> { // // @SafeVarargs // public CompoundServoCommand(ServoCommand<C>... commands) { // addAll(Arrays.asList(commands)); // } // // private static final long serialVersionUID = 1L; // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // }
import static com.iamcontent.device.servo.command.ImmutableServoCommand.immutableCommand; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ANKLE_INVERTER; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ANKLE_PLANTARFLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ELBOW_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_HIP_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_HIP_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_KNEE_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_SHOULDER_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_SHOULDER_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ANKLE_INVERTER; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ANKLE_PLANTARFLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ELBOW_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_HIP_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_HIP_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_KNEE_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_SHOULDER_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_SHOULDER_FLEXOR; import com.iamcontent.device.servo.command.CompoundServoCommand; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId;
package com.iamcontent.robot.robonova1.command; /** * A compound command to put a {@link Robonova} into a sitting position. * @author Greg Elderfield */ public class StandCommand extends CompoundServoCommand<ServoId> { public StandCommand() { super(
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/command/ImmutableServoCommand.java // public static <C> ServoCommand<C> immutableCommand(C channel, Double value, Double speed, Double acceleration) { // return new ImmutableServoCommand<C>(channel, value, speed, acceleration); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/command/CompoundServoCommand.java // public abstract class CompoundServoCommand<C> extends ArrayList<ServoCommand<C>> { // // @SafeVarargs // public CompoundServoCommand(ServoCommand<C>... commands) { // addAll(Arrays.asList(commands)); // } // // private static final long serialVersionUID = 1L; // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/ServoId.java // public enum ServoId { // LEFT_SHOULDER_FLEXOR, // RIGHT_SHOULDER_FLEXOR, // LEFT_SHOULDER_ABDUCTOR, // RIGHT_SHOULDER_ABDUCTOR, // LEFT_ELBOW_FLEXOR, // RIGHT_ELBOW_FLEXOR, // // LEFT_HIP_ABDUCTOR, // RIGHT_HIP_ABDUCTOR, // LEFT_HIP_FLEXOR, // RIGHT_HIP_FLEXOR, // LEFT_KNEE_FLEXOR, // RIGHT_KNEE_FLEXOR, // LEFT_ANKLE_PLANTARFLEXOR, // RIGHT_ANKLE_PLANTARFLEXOR, // LEFT_ANKLE_INVERTER, // RIGHT_ANKLE_INVERTER; // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/command/StandCommand.java import static com.iamcontent.device.servo.command.ImmutableServoCommand.immutableCommand; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ANKLE_INVERTER; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ANKLE_PLANTARFLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_ELBOW_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_HIP_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_HIP_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_KNEE_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_SHOULDER_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.LEFT_SHOULDER_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ANKLE_INVERTER; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ANKLE_PLANTARFLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_ELBOW_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_HIP_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_HIP_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_KNEE_FLEXOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_SHOULDER_ABDUCTOR; import static com.iamcontent.robot.robonova1.ServoId.RIGHT_SHOULDER_FLEXOR; import com.iamcontent.device.servo.command.CompoundServoCommand; import com.iamcontent.robot.robonova1.Robonova; import com.iamcontent.robot.robonova1.ServoId; package com.iamcontent.robot.robonova1.command; /** * A compound command to put a {@link Robonova} into a sitting position. * @author Greg Elderfield */ public class StandCommand extends CompoundServoCommand<ServoId> { public StandCommand() { super(
immutableCommand(LEFT_SHOULDER_FLEXOR, 0.5, 1.0, 0.02),
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCardIT.java
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/AbstractPololuMaestroServoCardIT.java // public abstract class AbstractPololuMaestroServoCardIT { // // private static final int CHANNEL = 0; // // private final double acceleration; // private final double speed; // private final double position; // private final double midPosition; // // public AbstractPololuMaestroServoCardIT(double acceleration, double speed, double position, double midPosition) { // this.acceleration = acceleration; // this.speed = speed; // this.position = position; // this.midPosition = midPosition; // } // // @Test // public void testRawDynamics() throws Exception { // resetDynamics(); // // setAcceleration(CHANNEL, acceleration); // setSpeed(CHANNEL, speed); // setPosition(CHANNEL, position); // // waitForServoPosition(CHANNEL, position); // // final double measuredPosition = getPosition(CHANNEL); // // assertEquals(position, measuredPosition, 0.0001); // } // // protected abstract void setAcceleration(int channel, double acceleration); // protected abstract void setSpeed(int channel, double speed); // protected abstract void setPosition(int channel, double position); // protected abstract double getPosition(int channel); // // private void waitForServoPosition(int channel, double position) { // ThreadUtils.sleepUntil(() -> getPosition(channel) == position, 5000, 20); // System.out.println("-----"); // } // // private void resetDynamics() { // setAcceleration(CHANNEL, (short) 0); // setSpeed(CHANNEL, (short) 0); // setPosition(CHANNEL, midPosition); // waitForServoPosition(CHANNEL, midPosition); // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // }
import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import com.iamcontent.device.controller.pololu.maestro.AbstractPololuMaestroServoCardIT; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * A simple integration test, which doubles as an example of how to use the maestro.usb package. * @author Greg Elderfield */ public class UsbPololuMaestroServoCardIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 120; private static final double SPEED = 50; private static final double POSITION = 7000; private static final double MID_POSITION = 6000;
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/AbstractPololuMaestroServoCardIT.java // public abstract class AbstractPololuMaestroServoCardIT { // // private static final int CHANNEL = 0; // // private final double acceleration; // private final double speed; // private final double position; // private final double midPosition; // // public AbstractPololuMaestroServoCardIT(double acceleration, double speed, double position, double midPosition) { // this.acceleration = acceleration; // this.speed = speed; // this.position = position; // this.midPosition = midPosition; // } // // @Test // public void testRawDynamics() throws Exception { // resetDynamics(); // // setAcceleration(CHANNEL, acceleration); // setSpeed(CHANNEL, speed); // setPosition(CHANNEL, position); // // waitForServoPosition(CHANNEL, position); // // final double measuredPosition = getPosition(CHANNEL); // // assertEquals(position, measuredPosition, 0.0001); // } // // protected abstract void setAcceleration(int channel, double acceleration); // protected abstract void setSpeed(int channel, double speed); // protected abstract void setPosition(int channel, double position); // protected abstract double getPosition(int channel); // // private void waitForServoPosition(int channel, double position) { // ThreadUtils.sleepUntil(() -> getPosition(channel) == position, 5000, 20); // System.out.println("-----"); // } // // private void resetDynamics() { // setAcceleration(CHANNEL, (short) 0); // setSpeed(CHANNEL, (short) 0); // setPosition(CHANNEL, midPosition); // waitForServoPosition(CHANNEL, midPosition); // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCardIT.java import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import com.iamcontent.device.controller.pololu.maestro.AbstractPololuMaestroServoCardIT; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * A simple integration test, which doubles as an example of how to use the maestro.usb package. * @author Greg Elderfield */ public class UsbPololuMaestroServoCardIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 120; private static final double SPEED = 50; private static final double POSITION = 7000; private static final double MID_POSITION = 6000;
private PololuMaestroServoCard card;
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCardIT.java
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/AbstractPololuMaestroServoCardIT.java // public abstract class AbstractPololuMaestroServoCardIT { // // private static final int CHANNEL = 0; // // private final double acceleration; // private final double speed; // private final double position; // private final double midPosition; // // public AbstractPololuMaestroServoCardIT(double acceleration, double speed, double position, double midPosition) { // this.acceleration = acceleration; // this.speed = speed; // this.position = position; // this.midPosition = midPosition; // } // // @Test // public void testRawDynamics() throws Exception { // resetDynamics(); // // setAcceleration(CHANNEL, acceleration); // setSpeed(CHANNEL, speed); // setPosition(CHANNEL, position); // // waitForServoPosition(CHANNEL, position); // // final double measuredPosition = getPosition(CHANNEL); // // assertEquals(position, measuredPosition, 0.0001); // } // // protected abstract void setAcceleration(int channel, double acceleration); // protected abstract void setSpeed(int channel, double speed); // protected abstract void setPosition(int channel, double position); // protected abstract double getPosition(int channel); // // private void waitForServoPosition(int channel, double position) { // ThreadUtils.sleepUntil(() -> getPosition(channel) == position, 5000, 20); // System.out.println("-----"); // } // // private void resetDynamics() { // setAcceleration(CHANNEL, (short) 0); // setSpeed(CHANNEL, (short) 0); // setPosition(CHANNEL, midPosition); // waitForServoPosition(CHANNEL, midPosition); // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // }
import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import com.iamcontent.device.controller.pololu.maestro.AbstractPololuMaestroServoCardIT; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * A simple integration test, which doubles as an example of how to use the maestro.usb package. * @author Greg Elderfield */ public class UsbPololuMaestroServoCardIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 120; private static final double SPEED = 50; private static final double POSITION = 7000; private static final double MID_POSITION = 6000; private PololuMaestroServoCard card; public UsbPololuMaestroServoCardIT() { super(ACCELERATION, SPEED, POSITION, MID_POSITION); } @Before public void setUp() { card = UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard(); } @Test public void testGetType() {
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/AbstractPololuMaestroServoCardIT.java // public abstract class AbstractPololuMaestroServoCardIT { // // private static final int CHANNEL = 0; // // private final double acceleration; // private final double speed; // private final double position; // private final double midPosition; // // public AbstractPololuMaestroServoCardIT(double acceleration, double speed, double position, double midPosition) { // this.acceleration = acceleration; // this.speed = speed; // this.position = position; // this.midPosition = midPosition; // } // // @Test // public void testRawDynamics() throws Exception { // resetDynamics(); // // setAcceleration(CHANNEL, acceleration); // setSpeed(CHANNEL, speed); // setPosition(CHANNEL, position); // // waitForServoPosition(CHANNEL, position); // // final double measuredPosition = getPosition(CHANNEL); // // assertEquals(position, measuredPosition, 0.0001); // } // // protected abstract void setAcceleration(int channel, double acceleration); // protected abstract void setSpeed(int channel, double speed); // protected abstract void setPosition(int channel, double position); // protected abstract double getPosition(int channel); // // private void waitForServoPosition(int channel, double position) { // ThreadUtils.sleepUntil(() -> getPosition(channel) == position, 5000, 20); // System.out.println("-----"); // } // // private void resetDynamics() { // setAcceleration(CHANNEL, (short) 0); // setSpeed(CHANNEL, (short) 0); // setPosition(CHANNEL, midPosition); // waitForServoPosition(CHANNEL, midPosition); // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCardIT.java import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import com.iamcontent.device.controller.pololu.maestro.AbstractPololuMaestroServoCardIT; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * A simple integration test, which doubles as an example of how to use the maestro.usb package. * @author Greg Elderfield */ public class UsbPololuMaestroServoCardIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 120; private static final double SPEED = 50; private static final double POSITION = 7000; private static final double MID_POSITION = 6000; private PololuMaestroServoCard card; public UsbPololuMaestroServoCardIT() { super(ACCELERATION, SPEED, POSITION, MID_POSITION); } @Before public void setUp() { card = UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard(); } @Test public void testGetType() {
final MaestroCardType cardType = getCardType();
IAmContent/public
public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/CommandHandler.java
// Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/CommandLineDriver.java // public static String tidied(String command) { // return command.trim().toLowerCase(); // }
import static com.iamcontent.io.cli.CommandLineDriver.tidied; import java.util.function.Predicate;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.cli; /** * An abstract class for implementing command handlers (i.e. Predicates which execute any command that they * understand (as a side-effect), returning true when a command is executed, false otherwise). * @author Greg Elderfield */ public abstract class CommandHandler implements Predicate<String> { @Override public boolean test(String command) { try {
// Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/CommandLineDriver.java // public static String tidied(String command) { // return command.trim().toLowerCase(); // } // Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/CommandHandler.java import static com.iamcontent.io.cli.CommandLineDriver.tidied; import java.util.function.Predicate; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.cli; /** * An abstract class for implementing command handlers (i.e. Predicates which execute any command that they * understand (as a side-effect), returning true when a command is executed, false otherwise). * @author Greg Elderfield */ public abstract class CommandHandler implements Predicate<String> { @Override public boolean test(String command) { try {
return executeIfCommandMatches(tidied(command));
IAmContent/public
public-java/devices/iamcontent-owi-motor-controllers/src/main/java/com/iamcontent/device/controller/owi/Owi535UsbMotorController.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java // public class Usb { // // public static EasyUsbDevice device(short vendorId, short productId) { // return first(devices(vendorId, productId)); // } // // public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { // return first(devices(shouldIncludeDevice)); // } // // public static List<EasyUsbDevice> devices(short vendorId, short productId) { // return devices(deviceHasVendorIdAndProductId(vendorId, productId)); // } // // public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) { // final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice); // deviceFinder.exploreRootUsbHub(); // return deviceFinder.getDevices(); // } // // public static UsbHub rootUsbHub() { // try { // return usbServices().getRootUsbHub(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // public static UsbServices usbServices() { // try { // return UsbHostManager.getUsbServices(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // private static <T> T first(List<T> l) { // try { // return l.get(0); // } catch (IndexOutOfBoundsException e) { // throw new UsbRuntimeException("No suitable USB Device found."); // } // } // // private Usb() { // } // }
import com.iamcontent.io.usb.EasyUsbDevice; import com.iamcontent.io.usb.Usb; import static com.iamcontent.io.usb.EasedUsbDevice.eased; import static java.util.Arrays.asList; import java.util.Arrays; import java.util.Collection; import java.util.EnumMap; import java.util.List; import java.util.Map; import javax.usb.UsbConst; import javax.usb.UsbControlIrp; import javax.usb.UsbDevice;
MOTOR_1_FORWARD(Actuator.MOTOR_1, (byte) 0x01), MOTOR_1_BACKWARD(Actuator.MOTOR_1, (byte) 0x02), MOTOR_1_STOP(Actuator.MOTOR_1, (byte) 0x00), MOTOR_2_FORWARD(Actuator.MOTOR_2, (byte) 0x04), MOTOR_2_BACKWARD(Actuator.MOTOR_2, (byte) 0x08), MOTOR_2_STOP(Actuator.MOTOR_2, (byte) 0x00), MOTOR_3_FORWARD(Actuator.MOTOR_3, (byte) 0x10), MOTOR_3_BACKWARD(Actuator.MOTOR_3, (byte) 0x20), MOTOR_3_STOP(Actuator.MOTOR_3, (byte) 0x00), MOTOR_4_FORWARD(Actuator.MOTOR_4, (byte) 0x40), MOTOR_4_BACKWARD(Actuator.MOTOR_4, (byte) 0x80), MOTOR_4_STOP(Actuator.MOTOR_4, (byte) 0x00), MOTOR_5_FORWARD(Actuator.MOTOR_5, (byte) 0x01), MOTOR_5_BACKWARD(Actuator.MOTOR_5, (byte) 0x02), MOTOR_5_STOP(Actuator.MOTOR_5, (byte) 0x00), LED_ON(Actuator.LED, (byte) 0x01), LED_OFF(Actuator.LED, (byte) 0x00); final Actuator actuator; final byte bits; private Command(Actuator actuator, byte bits) { this.actuator = actuator; this.bits = bits; } public Actuator getActuator() { return actuator; } } private final EasyUsbDevice device; private final Map<Actuator, Command> currentCommands = everythingTurnedOff(); /** * Creates an instance with the first OWI 535 device that is found. */ public Owi535UsbMotorController() { final short defaultVendorId = 0x1267; final short defaultProductId = 0x0;
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java // public class Usb { // // public static EasyUsbDevice device(short vendorId, short productId) { // return first(devices(vendorId, productId)); // } // // public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { // return first(devices(shouldIncludeDevice)); // } // // public static List<EasyUsbDevice> devices(short vendorId, short productId) { // return devices(deviceHasVendorIdAndProductId(vendorId, productId)); // } // // public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) { // final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice); // deviceFinder.exploreRootUsbHub(); // return deviceFinder.getDevices(); // } // // public static UsbHub rootUsbHub() { // try { // return usbServices().getRootUsbHub(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // public static UsbServices usbServices() { // try { // return UsbHostManager.getUsbServices(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // private static <T> T first(List<T> l) { // try { // return l.get(0); // } catch (IndexOutOfBoundsException e) { // throw new UsbRuntimeException("No suitable USB Device found."); // } // } // // private Usb() { // } // } // Path: public-java/devices/iamcontent-owi-motor-controllers/src/main/java/com/iamcontent/device/controller/owi/Owi535UsbMotorController.java import com.iamcontent.io.usb.EasyUsbDevice; import com.iamcontent.io.usb.Usb; import static com.iamcontent.io.usb.EasedUsbDevice.eased; import static java.util.Arrays.asList; import java.util.Arrays; import java.util.Collection; import java.util.EnumMap; import java.util.List; import java.util.Map; import javax.usb.UsbConst; import javax.usb.UsbControlIrp; import javax.usb.UsbDevice; MOTOR_1_FORWARD(Actuator.MOTOR_1, (byte) 0x01), MOTOR_1_BACKWARD(Actuator.MOTOR_1, (byte) 0x02), MOTOR_1_STOP(Actuator.MOTOR_1, (byte) 0x00), MOTOR_2_FORWARD(Actuator.MOTOR_2, (byte) 0x04), MOTOR_2_BACKWARD(Actuator.MOTOR_2, (byte) 0x08), MOTOR_2_STOP(Actuator.MOTOR_2, (byte) 0x00), MOTOR_3_FORWARD(Actuator.MOTOR_3, (byte) 0x10), MOTOR_3_BACKWARD(Actuator.MOTOR_3, (byte) 0x20), MOTOR_3_STOP(Actuator.MOTOR_3, (byte) 0x00), MOTOR_4_FORWARD(Actuator.MOTOR_4, (byte) 0x40), MOTOR_4_BACKWARD(Actuator.MOTOR_4, (byte) 0x80), MOTOR_4_STOP(Actuator.MOTOR_4, (byte) 0x00), MOTOR_5_FORWARD(Actuator.MOTOR_5, (byte) 0x01), MOTOR_5_BACKWARD(Actuator.MOTOR_5, (byte) 0x02), MOTOR_5_STOP(Actuator.MOTOR_5, (byte) 0x00), LED_ON(Actuator.LED, (byte) 0x01), LED_OFF(Actuator.LED, (byte) 0x00); final Actuator actuator; final byte bits; private Command(Actuator actuator, byte bits) { this.actuator = actuator; this.bits = bits; } public Actuator getActuator() { return actuator; } } private final EasyUsbDevice device; private final Map<Actuator, Command> currentCommands = everythingTurnedOff(); /** * Creates an instance with the first OWI 535 device that is found. */ public Owi535UsbMotorController() { final short defaultVendorId = 0x1267; final short defaultProductId = 0x0;
device = Usb.device(defaultVendorId, defaultProductId);
IAmContent/public
public-java/devices/iamcontent-owi-motor-controllers/src/main/java/com/iamcontent/device/controller/owi/Owi535UsbMotorController.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java // public class Usb { // // public static EasyUsbDevice device(short vendorId, short productId) { // return first(devices(vendorId, productId)); // } // // public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { // return first(devices(shouldIncludeDevice)); // } // // public static List<EasyUsbDevice> devices(short vendorId, short productId) { // return devices(deviceHasVendorIdAndProductId(vendorId, productId)); // } // // public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) { // final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice); // deviceFinder.exploreRootUsbHub(); // return deviceFinder.getDevices(); // } // // public static UsbHub rootUsbHub() { // try { // return usbServices().getRootUsbHub(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // public static UsbServices usbServices() { // try { // return UsbHostManager.getUsbServices(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // private static <T> T first(List<T> l) { // try { // return l.get(0); // } catch (IndexOutOfBoundsException e) { // throw new UsbRuntimeException("No suitable USB Device found."); // } // } // // private Usb() { // } // }
import com.iamcontent.io.usb.EasyUsbDevice; import com.iamcontent.io.usb.Usb; import static com.iamcontent.io.usb.EasedUsbDevice.eased; import static java.util.Arrays.asList; import java.util.Arrays; import java.util.Collection; import java.util.EnumMap; import java.util.List; import java.util.Map; import javax.usb.UsbConst; import javax.usb.UsbControlIrp; import javax.usb.UsbDevice;
final Actuator actuator; final byte bits; private Command(Actuator actuator, byte bits) { this.actuator = actuator; this.bits = bits; } public Actuator getActuator() { return actuator; } } private final EasyUsbDevice device; private final Map<Actuator, Command> currentCommands = everythingTurnedOff(); /** * Creates an instance with the first OWI 535 device that is found. */ public Owi535UsbMotorController() { final short defaultVendorId = 0x1267; final short defaultProductId = 0x0; device = Usb.device(defaultVendorId, defaultProductId); } /** * Creates an instance with the given UsbDevice. */ public Owi535UsbMotorController(UsbDevice device) {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java // public class Usb { // // public static EasyUsbDevice device(short vendorId, short productId) { // return first(devices(vendorId, productId)); // } // // public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { // return first(devices(shouldIncludeDevice)); // } // // public static List<EasyUsbDevice> devices(short vendorId, short productId) { // return devices(deviceHasVendorIdAndProductId(vendorId, productId)); // } // // public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) { // final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice); // deviceFinder.exploreRootUsbHub(); // return deviceFinder.getDevices(); // } // // public static UsbHub rootUsbHub() { // try { // return usbServices().getRootUsbHub(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // public static UsbServices usbServices() { // try { // return UsbHostManager.getUsbServices(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // private static <T> T first(List<T> l) { // try { // return l.get(0); // } catch (IndexOutOfBoundsException e) { // throw new UsbRuntimeException("No suitable USB Device found."); // } // } // // private Usb() { // } // } // Path: public-java/devices/iamcontent-owi-motor-controllers/src/main/java/com/iamcontent/device/controller/owi/Owi535UsbMotorController.java import com.iamcontent.io.usb.EasyUsbDevice; import com.iamcontent.io.usb.Usb; import static com.iamcontent.io.usb.EasedUsbDevice.eased; import static java.util.Arrays.asList; import java.util.Arrays; import java.util.Collection; import java.util.EnumMap; import java.util.List; import java.util.Map; import javax.usb.UsbConst; import javax.usb.UsbControlIrp; import javax.usb.UsbDevice; final Actuator actuator; final byte bits; private Command(Actuator actuator, byte bits) { this.actuator = actuator; this.bits = bits; } public Actuator getActuator() { return actuator; } } private final EasyUsbDevice device; private final Map<Actuator, Command> currentCommands = everythingTurnedOff(); /** * Creates an instance with the first OWI 535 device that is found. */ public Owi535UsbMotorController() { final short defaultVendorId = 0x1267; final short defaultProductId = 0x0; device = Usb.device(defaultVendorId, defaultProductId); } /** * Creates an instance with the given UsbDevice. */ public Owi535UsbMotorController(UsbDevice device) {
this.device = eased(device);
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // }
import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.servo.ServoController;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * Wraps a {@link PololuMaestroServoCard}, presenting it as a {@link ServoController}. * @author Greg Elderfield */ public class PololuMaestroServoController implements ServoController<Integer> { private final PololuMaestroServoCard card; public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { return new PololuMaestroServoController(card); } public PololuMaestroServoController(PololuMaestroServoCard card) { this.card = card; } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.servo.ServoController; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * Wraps a {@link PololuMaestroServoCard}, presenting it as a {@link ServoController}. * @author Greg Elderfield */ public class PololuMaestroServoController implements ServoController<Integer> { private final PololuMaestroServoCard card; public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { return new PololuMaestroServoController(card); } public PololuMaestroServoController(PololuMaestroServoCard card) { this.card = card; } @Override
public MutableDouble value(Integer channelId) {
IAmContent/public
public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.stream.Stream; import com.iamcontent.io.IORuntimeException;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.util; /** * Common I/O utilities. * @author Greg Elderfield */ public class IOUtils { /** * Appends the given String to the given Appendable. * @throws IORuntimeException, which is unchecked, if an {@link IOException} is thrown. */ public static void appendQuietly(Appendable out, String s) { try { out.append(s); } catch (IOException e) {
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.stream.Stream; import com.iamcontent.io.IORuntimeException; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.util; /** * Common I/O utilities. * @author Greg Elderfield */ public class IOUtils { /** * Appends the given String to the given Appendable. * @throws IORuntimeException, which is unchecked, if an {@link IOException} is thrown. */ public static void appendQuietly(Appendable out, String s) { try { out.append(s); } catch (IOException e) {
throw new IORuntimeException(e);
IAmContent/public
public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIO.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/lang/Delegator.java // public abstract class Delegator<D> { // private final D delegate; // // public Delegator(D delegate) { // requireNonNull(delegate, "Delegate cannot be null."); // this.delegate = delegate; // } // // protected D delegate() { // return delegate; // } // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java // public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIO calibrated(AnalogIOCalibration calibration) { // return new CalibratedAnalogIO(this, calibration); // } // // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOCalibration.java // public interface AnalogIOCalibration extends AnalogIOFeatures<DoubleConverter> { // static AnalogIOCalibration IDENTITY = new ImmutableAnalogIOCalibration(DoubleConverter.IDENTITY); // }
import com.iamcontent.core.lang.Delegator; import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.io.analog.AnalogIO; import com.iamcontent.device.io.analog.AnalogIOCalibration;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog.impl; /** * A {@link AnalogIO} that is a calibrated proxy for another (target) {@link AnalogIO}. * @author Greg Elderfield */ public class CalibratedAnalogIO extends Delegator<AnalogIO> implements AnalogIO { private final AnalogIOCalibration calibration; public CalibratedAnalogIO(AnalogIO target, AnalogIOCalibration calibration) { super(target); this.calibration = calibration; } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/lang/Delegator.java // public abstract class Delegator<D> { // private final D delegate; // // public Delegator(D delegate) { // requireNonNull(delegate, "Delegate cannot be null."); // this.delegate = delegate; // } // // protected D delegate() { // return delegate; // } // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java // public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIO calibrated(AnalogIOCalibration calibration) { // return new CalibratedAnalogIO(this, calibration); // } // // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOCalibration.java // public interface AnalogIOCalibration extends AnalogIOFeatures<DoubleConverter> { // static AnalogIOCalibration IDENTITY = new ImmutableAnalogIOCalibration(DoubleConverter.IDENTITY); // } // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIO.java import com.iamcontent.core.lang.Delegator; import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.io.analog.AnalogIO; import com.iamcontent.device.io.analog.AnalogIOCalibration; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog.impl; /** * A {@link AnalogIO} that is a calibrated proxy for another (target) {@link AnalogIO}. * @author Greg Elderfield */ public class CalibratedAnalogIO extends Delegator<AnalogIO> implements AnalogIO { private final AnalogIOCalibration calibration; public CalibratedAnalogIO(AnalogIO target, AnalogIOCalibration calibration) { super(target); this.calibration = calibration; } @Override
public MutableDouble value() {
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/RawPololuMaestroServoSourceIT.java
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java // public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { // return new PololuMaestroServoController(card); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java // public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() { // return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice())); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // }
import static com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoController.pololuMaestroServoController; import static com.iamcontent.device.controller.pololu.maestro.usb.UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard; import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; import com.iamcontent.device.servo.ServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * A simple integration test, which doubles as an example of how to drive a Pololu Maestro card as a raw {@link ServoSource}. * @author Greg Elderfield */ public class RawPololuMaestroServoSourceIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 120; private static final double SPEED = 50; private static final double POSITION = 7000; private static final double MID_POSITION = 6000;
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java // public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { // return new PololuMaestroServoController(card); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java // public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() { // return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice())); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/RawPololuMaestroServoSourceIT.java import static com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoController.pololuMaestroServoController; import static com.iamcontent.device.controller.pololu.maestro.usb.UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard; import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; import com.iamcontent.device.servo.ServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * A simple integration test, which doubles as an example of how to drive a Pololu Maestro card as a raw {@link ServoSource}. * @author Greg Elderfield */ public class RawPololuMaestroServoSourceIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 120; private static final double SPEED = 50; private static final double POSITION = 7000; private static final double MID_POSITION = 6000;
private ServoSource<Integer> rawServoSource;
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/RawPololuMaestroServoSourceIT.java
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java // public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { // return new PololuMaestroServoController(card); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java // public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() { // return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice())); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // }
import static com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoController.pololuMaestroServoController; import static com.iamcontent.device.controller.pololu.maestro.usb.UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard; import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; import com.iamcontent.device.servo.ServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * A simple integration test, which doubles as an example of how to drive a Pololu Maestro card as a raw {@link ServoSource}. * @author Greg Elderfield */ public class RawPololuMaestroServoSourceIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 120; private static final double SPEED = 50; private static final double POSITION = 7000; private static final double MID_POSITION = 6000; private ServoSource<Integer> rawServoSource; public RawPololuMaestroServoSourceIT() { super(ACCELERATION, SPEED, POSITION, MID_POSITION); } @Before public void setUp() { rawServoSource = rawServoSource(); } @Override protected void setAcceleration(int channel, double acceleration) { getServo(channel).acceleration().setValue(acceleration); } @Override protected void setSpeed(int channel, double speed) { getServo(channel).speed().setValue(speed); } @Override protected void setPosition(int channel, double position) { getServo(channel).value().setValue(position); } @Override protected double getPosition(int channel) { return getServo(channel).value().getValue(); }
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java // public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { // return new PololuMaestroServoController(card); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java // public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() { // return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice())); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/RawPololuMaestroServoSourceIT.java import static com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoController.pololuMaestroServoController; import static com.iamcontent.device.controller.pololu.maestro.usb.UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard; import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; import com.iamcontent.device.servo.ServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * A simple integration test, which doubles as an example of how to drive a Pololu Maestro card as a raw {@link ServoSource}. * @author Greg Elderfield */ public class RawPololuMaestroServoSourceIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 120; private static final double SPEED = 50; private static final double POSITION = 7000; private static final double MID_POSITION = 6000; private ServoSource<Integer> rawServoSource; public RawPololuMaestroServoSourceIT() { super(ACCELERATION, SPEED, POSITION, MID_POSITION); } @Before public void setUp() { rawServoSource = rawServoSource(); } @Override protected void setAcceleration(int channel, double acceleration) { getServo(channel).acceleration().setValue(acceleration); } @Override protected void setSpeed(int channel, double speed) { getServo(channel).speed().setValue(speed); } @Override protected void setPosition(int channel, double position) { getServo(channel).value().setValue(position); } @Override protected double getPosition(int channel) { return getServo(channel).value().getValue(); }
private Servo getServo(int channel) {
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/RawPololuMaestroServoSourceIT.java
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java // public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { // return new PololuMaestroServoController(card); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java // public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() { // return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice())); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // }
import static com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoController.pololuMaestroServoController; import static com.iamcontent.device.controller.pololu.maestro.usb.UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard; import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; import com.iamcontent.device.servo.ServoSource;
} @Override protected void setAcceleration(int channel, double acceleration) { getServo(channel).acceleration().setValue(acceleration); } @Override protected void setSpeed(int channel, double speed) { getServo(channel).speed().setValue(speed); } @Override protected void setPosition(int channel, double position) { getServo(channel).value().setValue(position); } @Override protected double getPosition(int channel) { return getServo(channel).value().getValue(); } private Servo getServo(int channel) { return rawServoSource.forChannel(channel); } protected static ServoSource<Integer> rawServoSource() { return ServoSource.rawServoSource(defaultServoController()); }
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java // public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { // return new PololuMaestroServoController(card); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java // public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() { // return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice())); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/RawPololuMaestroServoSourceIT.java import static com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoController.pololuMaestroServoController; import static com.iamcontent.device.controller.pololu.maestro.usb.UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard; import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; import com.iamcontent.device.servo.ServoSource; } @Override protected void setAcceleration(int channel, double acceleration) { getServo(channel).acceleration().setValue(acceleration); } @Override protected void setSpeed(int channel, double speed) { getServo(channel).speed().setValue(speed); } @Override protected void setPosition(int channel, double position) { getServo(channel).value().setValue(position); } @Override protected double getPosition(int channel) { return getServo(channel).value().getValue(); } private Servo getServo(int channel) { return rawServoSource.forChannel(channel); } protected static ServoSource<Integer> rawServoSource() { return ServoSource.rawServoSource(defaultServoController()); }
private static ServoController<Integer> defaultServoController() {
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/RawPololuMaestroServoSourceIT.java
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java // public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { // return new PololuMaestroServoController(card); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java // public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() { // return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice())); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // }
import static com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoController.pololuMaestroServoController; import static com.iamcontent.device.controller.pololu.maestro.usb.UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard; import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; import com.iamcontent.device.servo.ServoSource;
@Override protected void setAcceleration(int channel, double acceleration) { getServo(channel).acceleration().setValue(acceleration); } @Override protected void setSpeed(int channel, double speed) { getServo(channel).speed().setValue(speed); } @Override protected void setPosition(int channel, double position) { getServo(channel).value().setValue(position); } @Override protected double getPosition(int channel) { return getServo(channel).value().getValue(); } private Servo getServo(int channel) { return rawServoSource.forChannel(channel); } protected static ServoSource<Integer> rawServoSource() { return ServoSource.rawServoSource(defaultServoController()); } private static ServoController<Integer> defaultServoController() {
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java // public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { // return new PololuMaestroServoController(card); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java // public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() { // return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice())); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/RawPololuMaestroServoSourceIT.java import static com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoController.pololuMaestroServoController; import static com.iamcontent.device.controller.pololu.maestro.usb.UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard; import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; import com.iamcontent.device.servo.ServoSource; @Override protected void setAcceleration(int channel, double acceleration) { getServo(channel).acceleration().setValue(acceleration); } @Override protected void setSpeed(int channel, double speed) { getServo(channel).speed().setValue(speed); } @Override protected void setPosition(int channel, double position) { getServo(channel).value().setValue(position); } @Override protected double getPosition(int channel) { return getServo(channel).value().getValue(); } private Servo getServo(int channel) { return rawServoSource.forChannel(channel); } protected static ServoSource<Integer> rawServoSource() { return ServoSource.rawServoSource(defaultServoController()); } private static ServoController<Integer> defaultServoController() {
return pololuMaestroServoController(defaultUsbPololuMaestroServoCard());
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/RawPololuMaestroServoSourceIT.java
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java // public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { // return new PololuMaestroServoController(card); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java // public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() { // return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice())); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // }
import static com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoController.pololuMaestroServoController; import static com.iamcontent.device.controller.pololu.maestro.usb.UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard; import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; import com.iamcontent.device.servo.ServoSource;
@Override protected void setAcceleration(int channel, double acceleration) { getServo(channel).acceleration().setValue(acceleration); } @Override protected void setSpeed(int channel, double speed) { getServo(channel).speed().setValue(speed); } @Override protected void setPosition(int channel, double position) { getServo(channel).value().setValue(position); } @Override protected double getPosition(int channel) { return getServo(channel).value().getValue(); } private Servo getServo(int channel) { return rawServoSource.forChannel(channel); } protected static ServoSource<Integer> rawServoSource() { return ServoSource.rawServoSource(defaultServoController()); } private static ServoController<Integer> defaultServoController() {
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoController.java // public static PololuMaestroServoController pololuMaestroServoController(PololuMaestroServoCard card) { // return new PololuMaestroServoController(card); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java // public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() { // return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice())); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/RawPololuMaestroServoSourceIT.java import static com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoController.pololuMaestroServoController; import static com.iamcontent.device.controller.pololu.maestro.usb.UsbPololuMaestroServoCards.defaultUsbPololuMaestroServoCard; import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; import com.iamcontent.device.servo.ServoSource; @Override protected void setAcceleration(int channel, double acceleration) { getServo(channel).acceleration().setValue(acceleration); } @Override protected void setSpeed(int channel, double speed) { getServo(channel).speed().setValue(speed); } @Override protected void setPosition(int channel, double position) { getServo(channel).value().setValue(position); } @Override protected double getPosition(int channel) { return getServo(channel).value().getValue(); } private Servo getServo(int channel) { return rawServoSource.forChannel(channel); } protected static ServoSource<Integer> rawServoSource() { return ServoSource.rawServoSource(defaultServoController()); } private static ServoController<Integer> defaultServoController() {
return pololuMaestroServoController(defaultUsbPololuMaestroServoCard());
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServo.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIO.java // public class CalibratedAnalogIO extends Delegator<AnalogIO> implements AnalogIO { // // private final AnalogIOCalibration calibration; // // public CalibratedAnalogIO(AnalogIO target, AnalogIOCalibration calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public MutableDouble value() { // return delegate().value().calibrated(calibration().value()); // } // // protected AnalogIOCalibration calibration() { // return calibration; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoCalibration.java // public interface ServoCalibration extends AnalogIOCalibration, ServoFeatures<DoubleConverter> { // static ServoCalibration IDENTITY = new ImmutableServoCalibration(DoubleConverter.IDENTITY); // }
import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.io.analog.impl.CalibratedAnalogIO; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoCalibration;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo.impl; /** * A MutableDouble that is a calibrated proxy for another (target) MutableDouble. * @author Greg Elderfield */ public class CalibratedServo extends CalibratedAnalogIO implements Servo { public CalibratedServo(Servo target, ServoCalibration calibration) { super(target, calibration); } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIO.java // public class CalibratedAnalogIO extends Delegator<AnalogIO> implements AnalogIO { // // private final AnalogIOCalibration calibration; // // public CalibratedAnalogIO(AnalogIO target, AnalogIOCalibration calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public MutableDouble value() { // return delegate().value().calibrated(calibration().value()); // } // // protected AnalogIOCalibration calibration() { // return calibration; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoCalibration.java // public interface ServoCalibration extends AnalogIOCalibration, ServoFeatures<DoubleConverter> { // static ServoCalibration IDENTITY = new ImmutableServoCalibration(DoubleConverter.IDENTITY); // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServo.java import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.io.analog.impl.CalibratedAnalogIO; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoCalibration; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo.impl; /** * A MutableDouble that is a calibrated proxy for another (target) MutableDouble. * @author Greg Elderfield */ public class CalibratedServo extends CalibratedAnalogIO implements Servo { public CalibratedServo(Servo target, ServoCalibration calibration) { super(target, calibration); } @Override
public MutableDouble value() {
IAmContent/public
public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // }
import static com.iamcontent.io.usb.EasedUsbDevice.eased; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.Predicate; import javax.usb.UsbDevice; import com.iamcontent.io.usb.EasyUsbDevice;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb.topology; /** * Explores a USB topology and composes a list of the devices that match the given predicate. * @author Greg Elderfield */ public class UsbDeviceFinder extends UsbTopologyExplorer { public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { super(shouldIncludeDevice); } public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { return new UsbDeviceFinder(shouldIncludeDevice); }
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // } // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java import static com.iamcontent.io.usb.EasedUsbDevice.eased; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.Predicate; import javax.usb.UsbDevice; import com.iamcontent.io.usb.EasyUsbDevice; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb.topology; /** * Explores a USB topology and composes a list of the devices that match the given predicate. * @author Greg Elderfield */ public class UsbDeviceFinder extends UsbTopologyExplorer { public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { super(shouldIncludeDevice); } public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { return new UsbDeviceFinder(shouldIncludeDevice); }
private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>();
IAmContent/public
public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // }
import static com.iamcontent.io.usb.EasedUsbDevice.eased; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.Predicate; import javax.usb.UsbDevice; import com.iamcontent.io.usb.EasyUsbDevice;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb.topology; /** * Explores a USB topology and composes a list of the devices that match the given predicate. * @author Greg Elderfield */ public class UsbDeviceFinder extends UsbTopologyExplorer { public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { super(shouldIncludeDevice); } public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { return new UsbDeviceFinder(shouldIncludeDevice); } private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>(); @Override public void visit(UsbDevice usbDevice) {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // } // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java import static com.iamcontent.io.usb.EasedUsbDevice.eased; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.Predicate; import javax.usb.UsbDevice; import com.iamcontent.io.usb.EasyUsbDevice; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb.topology; /** * Explores a USB topology and composes a list of the devices that match the given predicate. * @author Greg Elderfield */ public class UsbDeviceFinder extends UsbTopologyExplorer { public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { super(shouldIncludeDevice); } public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { return new UsbDeviceFinder(shouldIncludeDevice); } private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>(); @Override public void visit(UsbDevice usbDevice) {
devices.add(eased(usbDevice));
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/AbstractUsbPololuMaestroServoCard.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // }
import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard; import com.iamcontent.io.usb.EasyUsbDevice; import static com.iamcontent.io.usb.EasedUsbDevice.eased; import static java.util.stream.Collectors.joining; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_IN; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_OUT; import static javax.usb.UsbConst.REQUESTTYPE_TYPE_VENDOR; import java.io.Serializable; import java.util.stream.IntStream; import javax.usb.UsbControlIrp; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * An abstract {@link PololuMaestroServoCard} that uses Pololu's Native USB protocol. * Methods with implementations that vary by card type must be provided by concrete subclasses. * * The command values used by this protocol were obtained from Pololu's Native USB SDK, * downloaded from www.pololu.com. * * @author Greg Elderfield */ public abstract class AbstractUsbPololuMaestroServoCard implements PololuMaestroServoCard { private static final byte REQUEST_SET_TARGET = (byte)0x85; private static final byte REQUEST_SET_SERVO_VARIABLE = (byte)0x84; private static final int BYTES_PER_SERVO_STATUS_BLOCK = 7;
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/AbstractUsbPololuMaestroServoCard.java import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard; import com.iamcontent.io.usb.EasyUsbDevice; import static com.iamcontent.io.usb.EasedUsbDevice.eased; import static java.util.stream.Collectors.joining; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_IN; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_OUT; import static javax.usb.UsbConst.REQUESTTYPE_TYPE_VENDOR; import java.io.Serializable; import java.util.stream.IntStream; import javax.usb.UsbControlIrp; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * An abstract {@link PololuMaestroServoCard} that uses Pololu's Native USB protocol. * Methods with implementations that vary by card type must be provided by concrete subclasses. * * The command values used by this protocol were obtained from Pololu's Native USB SDK, * downloaded from www.pololu.com. * * @author Greg Elderfield */ public abstract class AbstractUsbPololuMaestroServoCard implements PololuMaestroServoCard { private static final byte REQUEST_SET_TARGET = (byte)0x85; private static final byte REQUEST_SET_SERVO_VARIABLE = (byte)0x84; private static final int BYTES_PER_SERVO_STATUS_BLOCK = 7;
private final EasyUsbDevice device;
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/AbstractUsbPololuMaestroServoCard.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // }
import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard; import com.iamcontent.io.usb.EasyUsbDevice; import static com.iamcontent.io.usb.EasedUsbDevice.eased; import static java.util.stream.Collectors.joining; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_IN; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_OUT; import static javax.usb.UsbConst.REQUESTTYPE_TYPE_VENDOR; import java.io.Serializable; import java.util.stream.IntStream; import javax.usb.UsbControlIrp; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * An abstract {@link PololuMaestroServoCard} that uses Pololu's Native USB protocol. * Methods with implementations that vary by card type must be provided by concrete subclasses. * * The command values used by this protocol were obtained from Pololu's Native USB SDK, * downloaded from www.pololu.com. * * @author Greg Elderfield */ public abstract class AbstractUsbPololuMaestroServoCard implements PololuMaestroServoCard { private static final byte REQUEST_SET_TARGET = (byte)0x85; private static final byte REQUEST_SET_SERVO_VARIABLE = (byte)0x84; private static final int BYTES_PER_SERVO_STATUS_BLOCK = 7; private final EasyUsbDevice device; private final UsbMaestroCardType type; private final byte[] dataIn; private final byte inRequestCode; private final int offsetOfFirstServoStatusBlock; /** * Creates an instance with the given UsbDevice. */ public AbstractUsbPololuMaestroServoCard(UsbDevice device, byte inRequestCode, int offsetOfFirstServoStatusBlock) {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/AbstractUsbPololuMaestroServoCard.java import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard; import com.iamcontent.io.usb.EasyUsbDevice; import static com.iamcontent.io.usb.EasedUsbDevice.eased; import static java.util.stream.Collectors.joining; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_IN; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_OUT; import static javax.usb.UsbConst.REQUESTTYPE_TYPE_VENDOR; import java.io.Serializable; import java.util.stream.IntStream; import javax.usb.UsbControlIrp; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * An abstract {@link PololuMaestroServoCard} that uses Pololu's Native USB protocol. * Methods with implementations that vary by card type must be provided by concrete subclasses. * * The command values used by this protocol were obtained from Pololu's Native USB SDK, * downloaded from www.pololu.com. * * @author Greg Elderfield */ public abstract class AbstractUsbPololuMaestroServoCard implements PololuMaestroServoCard { private static final byte REQUEST_SET_TARGET = (byte)0x85; private static final byte REQUEST_SET_SERVO_VARIABLE = (byte)0x84; private static final int BYTES_PER_SERVO_STATUS_BLOCK = 7; private final EasyUsbDevice device; private final UsbMaestroCardType type; private final byte[] dataIn; private final byte inRequestCode; private final int offsetOfFirstServoStatusBlock; /** * Creates an instance with the given UsbDevice. */ public AbstractUsbPololuMaestroServoCard(UsbDevice device, byte inRequestCode, int offsetOfFirstServoStatusBlock) {
this.device = eased(device);
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/AbstractUsbPololuMaestroServoCard.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // }
import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard; import com.iamcontent.io.usb.EasyUsbDevice; import static com.iamcontent.io.usb.EasedUsbDevice.eased; import static java.util.stream.Collectors.joining; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_IN; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_OUT; import static javax.usb.UsbConst.REQUESTTYPE_TYPE_VENDOR; import java.io.Serializable; import java.util.stream.IntStream; import javax.usb.UsbControlIrp; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType;
@Override public void setPosition(short channel, short position) { device.syncSubmit(outRequest(REQUEST_SET_TARGET, chan(channel), position)); } @Override public void setSpeed(short channel, short speed) { device.syncSubmit(outRequest(REQUEST_SET_SERVO_VARIABLE, chan(channel), speed)); } @Override public void setAcceleration(short channel, short acceleration) { final int accelerationFlag = 0x80; device.syncSubmit(outRequest(REQUEST_SET_SERVO_VARIABLE, (short)(chan(channel) | accelerationFlag), acceleration)); } @Override public short getPosition(short channel) { return getState().getPosition(chan(channel)); } @Override public State getState() { final UsbControlIrp request = inRequest(inRequestCode); device.syncSubmit(request); return new PololuState(request.getData()); } @Override
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasedUsbDevice.java // public static EasedUsbDevice eased(UsbDevice device) { // if (device instanceof EasyUsbDevice) // return (EasedUsbDevice) device; // else // return new EasedUsbDevice(device); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/EasyUsbDevice.java // @SuppressWarnings("rawtypes") // public interface EasyUsbDevice extends UsbDevice { // String getManufacturerString(); // // String getSerialNumberString(); // // String getProductString(); // // UsbStringDescriptor getUsbStringDescriptor(byte index); // // String getString(byte index); // // void syncSubmit(UsbControlIrp irp); // // void asyncSubmit(UsbControlIrp irp); // // void syncSubmit(List list); // // void asyncSubmit(List list); // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/AbstractUsbPololuMaestroServoCard.java import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard; import com.iamcontent.io.usb.EasyUsbDevice; import static com.iamcontent.io.usb.EasedUsbDevice.eased; import static java.util.stream.Collectors.joining; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_IN; import static javax.usb.UsbConst.REQUESTTYPE_DIRECTION_OUT; import static javax.usb.UsbConst.REQUESTTYPE_TYPE_VENDOR; import java.io.Serializable; import java.util.stream.IntStream; import javax.usb.UsbControlIrp; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; @Override public void setPosition(short channel, short position) { device.syncSubmit(outRequest(REQUEST_SET_TARGET, chan(channel), position)); } @Override public void setSpeed(short channel, short speed) { device.syncSubmit(outRequest(REQUEST_SET_SERVO_VARIABLE, chan(channel), speed)); } @Override public void setAcceleration(short channel, short acceleration) { final int accelerationFlag = 0x80; device.syncSubmit(outRequest(REQUEST_SET_SERVO_VARIABLE, (short)(chan(channel) | accelerationFlag), acceleration)); } @Override public short getPosition(short channel) { return getState().getPosition(chan(channel)); } @Override public State getState() { final UsbControlIrp request = inRequest(inRequestCode); device.syncSubmit(request); return new PololuState(request.getData()); } @Override
public MaestroCardType getType() {
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RawServo.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // }
import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo.impl; /** * A {@link Servo} that directly delegates its operations to a {@link ServoController} without altering the * arguments of the operations. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public class RawServo<C> implements Servo { protected final ServoController<C> controller; protected final C channelId; public RawServo(ServoController<C> controller, C channelId) { this.controller = controller; this.channelId = channelId; } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoController.java // public interface ServoController<C> extends AnalogIOController<C> { // MutableDouble speed(C channelId); // MutableDouble acceleration(C channelId); // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RawServo.java import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoController; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo.impl; /** * A {@link Servo} that directly delegates its operations to a {@link ServoController} without altering the * arguments of the operations. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public class RawServo<C> implements Servo { protected final ServoController<C> controller; protected final C channelId; public RawServo(ServoController<C> controller, C channelId) { this.controller = controller; this.channelId = channelId; } @Override
public MutableDouble value() {
IAmContent/public
public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/InterRangeDoubleConverterTest.java
// Path: public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/MathUtilsTest.java // public static void assertCloseEnough(double expected, double actual) { // assertEquals(expected, actual, TOLERANCE); // }
import static com.iamcontent.core.math.InterRangeDoubleConverter.ClampingMode.CLAMPED; import static com.iamcontent.core.math.InterRangeDoubleConverter.ClampingMode.UNCLAMPED; import static com.iamcontent.core.math.MathUtilsTest.assertCloseEnough; import org.junit.Test;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.core.math; public class InterRangeDoubleConverterTest { private static final DoubleRange RANGE_1 = new DoubleRange(2, 3); private static final DoubleRange RANGE_2 = new DoubleRange(-20, -30); @Test public void testApplyForward_clamped() { final InterRangeDoubleConverter c = new InterRangeDoubleConverter(RANGE_1, RANGE_2, CLAMPED);
// Path: public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/MathUtilsTest.java // public static void assertCloseEnough(double expected, double actual) { // assertEquals(expected, actual, TOLERANCE); // } // Path: public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/InterRangeDoubleConverterTest.java import static com.iamcontent.core.math.InterRangeDoubleConverter.ClampingMode.CLAMPED; import static com.iamcontent.core.math.InterRangeDoubleConverter.ClampingMode.UNCLAMPED; import static com.iamcontent.core.math.MathUtilsTest.assertCloseEnough; import org.junit.Test; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.core.math; public class InterRangeDoubleConverterTest { private static final DoubleRange RANGE_1 = new DoubleRange(2, 3); private static final DoubleRange RANGE_2 = new DoubleRange(-20, -30); @Test public void testApplyForward_clamped() { final InterRangeDoubleConverter c = new InterRangeDoubleConverter(RANGE_1, RANGE_2, CLAMPED);
assertCloseEnough(-20.0, c.applyForward(1.0));
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RemappedServoSource.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/lang/Delegator.java // public abstract class Delegator<D> { // private final D delegate; // // public Delegator(D delegate) { // requireNonNull(delegate, "Delegate cannot be null."); // this.delegate = delegate; // } // // protected D delegate() { // return delegate; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // }
import java.util.function.Function; import com.iamcontent.core.lang.Delegator; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo.impl; /** * A {@link ServoSource} that has new channel ids, as defined by a mapping function. * * @author Greg Elderfield */ public class RemappedServoSource<NewChannelId, DelegateChannelId> extends Delegator<ServoSource<DelegateChannelId>> implements ServoSource<NewChannelId> { protected final Function<NewChannelId, DelegateChannelId> remapping; public RemappedServoSource(ServoSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { super(target); this.remapping = remapping; } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/lang/Delegator.java // public abstract class Delegator<D> { // private final D delegate; // // public Delegator(D delegate) { // requireNonNull(delegate, "Delegate cannot be null."); // this.delegate = delegate; // } // // protected D delegate() { // return delegate; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/RemappedServoSource.java import java.util.function.Function; import com.iamcontent.core.lang.Delegator; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo.impl; /** * A {@link ServoSource} that has new channel ids, as defined by a mapping function. * * @author Greg Elderfield */ public class RemappedServoSource<NewChannelId, DelegateChannelId> extends Delegator<ServoSource<DelegateChannelId>> implements ServoSource<NewChannelId> { protected final Function<NewChannelId, DelegateChannelId> remapping; public RemappedServoSource(ServoSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { super(target); this.remapping = remapping; } @Override
public Servo forChannel(NewChannelId channelId) {
IAmContent/public
public-java/io/iamcontent-usb/src/test/java/com/iamcontent/io/usb/UsbTestDriver.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/license/License.java // public static void displayLicense() { // for (String s : MINIMAL_TERMS) // System.out.println(s); // }
import static com.iamcontent.io.usb.license.License.displayLicense; import java.util.List;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb; /** * Searches for a USB device with a given vendor id and product id. * @author Greg Elderfield */ public class UsbTestDriver { public static void main(String[] args) { try {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/license/License.java // public static void displayLicense() { // for (String s : MINIMAL_TERMS) // System.out.println(s); // } // Path: public-java/io/iamcontent-usb/src/test/java/com/iamcontent/io/usb/UsbTestDriver.java import static com.iamcontent.io.usb.license.License.displayLicense; import java.util.List; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb; /** * Searches for a USB device with a given vendor id and product id. * @author Greg Elderfield */ public class UsbTestDriver { public static void main(String[] args) { try {
displayLicense();
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/CalibratedPololuMaestroServoSourceIT.java
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // }
import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * A simple integration test, which doubles as an example of how to drive a Pololu Maestro card as a calibrated {@link ServoSource}. * @author Greg Elderfield */ public class CalibratedPololuMaestroServoSourceIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 0.5; private static final double SPEED = 0.7; private static final double POSITION = 0.8; private static final double MID_POSITION = 0.5;
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/CalibratedPololuMaestroServoSourceIT.java import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * A simple integration test, which doubles as an example of how to drive a Pololu Maestro card as a calibrated {@link ServoSource}. * @author Greg Elderfield */ public class CalibratedPololuMaestroServoSourceIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 0.5; private static final double SPEED = 0.7; private static final double POSITION = 0.8; private static final double MID_POSITION = 0.5;
private ServoSource<Integer> calibratedServoSource;
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/CalibratedPololuMaestroServoSourceIT.java
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // }
import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * A simple integration test, which doubles as an example of how to drive a Pololu Maestro card as a calibrated {@link ServoSource}. * @author Greg Elderfield */ public class CalibratedPololuMaestroServoSourceIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 0.5; private static final double SPEED = 0.7; private static final double POSITION = 0.8; private static final double MID_POSITION = 0.5; private ServoSource<Integer> calibratedServoSource; public CalibratedPololuMaestroServoSourceIT() { super(ACCELERATION, SPEED, POSITION, MID_POSITION); } @Before public void setUp() { calibratedServoSource = DefaultPololuServoConfig.normalServos(); } @Override protected void setAcceleration(int channel, double acceleration) { getServo(channel).acceleration().setValue(acceleration); } @Override protected void setSpeed(int channel, double speed) { getServo(channel).speed().setValue(speed); } @Override protected void setPosition(int channel, double position) { getServo(channel).value().setValue(position); } @Override protected double getPosition(int channel) { return getServo(channel).value().getValue(); }
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/CalibratedPololuMaestroServoSourceIT.java import org.junit.Before; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * A simple integration test, which doubles as an example of how to drive a Pololu Maestro card as a calibrated {@link ServoSource}. * @author Greg Elderfield */ public class CalibratedPololuMaestroServoSourceIT extends AbstractPololuMaestroServoCardIT { private static final double ACCELERATION = 0.5; private static final double SPEED = 0.7; private static final double POSITION = 0.8; private static final double MID_POSITION = 0.5; private ServoSource<Integer> calibratedServoSource; public CalibratedPololuMaestroServoSourceIT() { super(ACCELERATION, SPEED, POSITION, MID_POSITION); } @Before public void setUp() { calibratedServoSource = DefaultPololuServoConfig.normalServos(); } @Override protected void setAcceleration(int channel, double acceleration) { getServo(channel).acceleration().setValue(acceleration); } @Override protected void setSpeed(int channel, double speed) { getServo(channel).speed().setValue(speed); } @Override protected void setPosition(int channel, double position) { getServo(channel).value().setValue(position); } @Override protected double getPosition(int channel) { return getServo(channel).value().getValue(); }
private Servo getServo(int channel) {
IAmContent/public
public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIOSource.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/lang/Delegator.java // public abstract class Delegator<D> { // private final D delegate; // // public Delegator(D delegate) { // requireNonNull(delegate, "Delegate cannot be null."); // this.delegate = delegate; // } // // protected D delegate() { // return delegate; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java // public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIO calibrated(AnalogIOCalibration calibration) { // return new CalibratedAnalogIO(this, calibration); // } // // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSourceCalibration.java // public interface AnalogIOSourceCalibration<C> extends PerChannelSource<C, AnalogIOCalibration> { // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration(AnalogIOCalibration calibration) { // return new DefaultingAnalogIOSourceCalibration<C>(calibration); // } // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration() { // return analogIOSourceCalibration(AnalogIOCalibration.IDENTITY); // } // }
import com.iamcontent.core.lang.Delegator; import com.iamcontent.device.io.analog.AnalogIO; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.io.analog.AnalogIOSourceCalibration;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog.impl; /** * An {@link AnalogIOSource} that returns calibrated proxies of the {@link AnalogIO}s from another (target) {@link AnalogIOSource}. * {@link AnalogIO}s are calibrated using the coresponding calibrator from the {@link AnalogIOSourceCalibration} * * @param <C> The type used to identify an analog input/output channel. * * @author Greg Elderfield */ public class CalibratedAnalogIOSource<C> extends Delegator<AnalogIOSource<C>> implements AnalogIOSource<C> { private final AnalogIOSourceCalibration<C> calibration; public CalibratedAnalogIOSource(AnalogIOSource<C> target, AnalogIOSourceCalibration<C> calibration) { super(target); this.calibration = calibration; } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/lang/Delegator.java // public abstract class Delegator<D> { // private final D delegate; // // public Delegator(D delegate) { // requireNonNull(delegate, "Delegate cannot be null."); // this.delegate = delegate; // } // // protected D delegate() { // return delegate; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java // public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIO calibrated(AnalogIOCalibration calibration) { // return new CalibratedAnalogIO(this, calibration); // } // // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSourceCalibration.java // public interface AnalogIOSourceCalibration<C> extends PerChannelSource<C, AnalogIOCalibration> { // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration(AnalogIOCalibration calibration) { // return new DefaultingAnalogIOSourceCalibration<C>(calibration); // } // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration() { // return analogIOSourceCalibration(AnalogIOCalibration.IDENTITY); // } // } // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIOSource.java import com.iamcontent.core.lang.Delegator; import com.iamcontent.device.io.analog.AnalogIO; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.io.analog.AnalogIOSourceCalibration; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog.impl; /** * An {@link AnalogIOSource} that returns calibrated proxies of the {@link AnalogIO}s from another (target) {@link AnalogIOSource}. * {@link AnalogIO}s are calibrated using the coresponding calibrator from the {@link AnalogIOSourceCalibration} * * @param <C> The type used to identify an analog input/output channel. * * @author Greg Elderfield */ public class CalibratedAnalogIOSource<C> extends Delegator<AnalogIOSource<C>> implements AnalogIOSource<C> { private final AnalogIOSourceCalibration<C> calibration; public CalibratedAnalogIOSource(AnalogIOSource<C> target, AnalogIOSourceCalibration<C> calibration) { super(target); this.calibration = calibration; } @Override
public AnalogIO forChannel(C channelId) {
IAmContent/public
public-java/robots/iamcontent-robotic-arm-edge/src/main/java/com/iamcontent/robot/arm/edge/ParseStringIntoCommandFunction.java
// Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/CommandLineDriver.java // public static String tidied(String command) { // return command.trim().toLowerCase(); // } // // Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/UnknownCommandException.java // public class UnknownCommandException extends RuntimeException { // public UnknownCommandException(String command) { // super("Unknown command: " + command); // } // // private static final long serialVersionUID = 1L; // } // // Path: public-java/robots/iamcontent-robotic-arm-edge/src/main/java/com/iamcontent/robot/arm/edge/RoboticEdgeArm.java // public enum Command { // GRIPPER_CLOSE(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_FORWARD), // GRIPPER_OPEN(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_BACKWARD), // GRIPPER_STOP(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_STOP), // // WRIST_EXTEND(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_FORWARD), // WRIST_FLEX(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_BACKWARD), // WRIST_STOP(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_STOP), // // ELBOW_EXTEND(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_FORWARD), // ELBOW_FLEX(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_BACKWARD), // ELBOW_STOP(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_STOP), // // SHOULDER_BACKWARD(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_FORWARD), // SHOULDER_FORWARD(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_BACKWARD), // SHOULDER_STOP(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_STOP), // // BASE_RIGHT(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_FORWARD), // BASE_LEFT(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_BACKWARD), // BASE_STOP(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_STOP), // // LED_ON(Actuator.LED, Owi535UsbMotorController.Command.LED_ON), // LED_OFF(Actuator.LED, Owi535UsbMotorController.Command.LED_OFF); // // final Actuator actuator; // final Owi535UsbMotorController.Command controllerCommand; // // private Command(Actuator actuator, Owi535UsbMotorController.Command controllerCommand) { // this.actuator = actuator; // this.controllerCommand = controllerCommand; // } // public Actuator getActuator() { // return actuator; // } // public Owi535UsbMotorController.Command getControllerCommand() { // return controllerCommand; // } // };
import com.iamcontent.robot.arm.edge.RoboticEdgeArm.Command; import static com.iamcontent.io.cli.CommandLineDriver.tidied; import java.util.function.Function; import com.iamcontent.io.cli.UnknownCommandException;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.arm.edge; /** * A function to parse a String command into a {@link Command}. */ public class ParseStringIntoCommandFunction implements Function<String, Command> { @Override public Command apply(String command) {
// Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/CommandLineDriver.java // public static String tidied(String command) { // return command.trim().toLowerCase(); // } // // Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/UnknownCommandException.java // public class UnknownCommandException extends RuntimeException { // public UnknownCommandException(String command) { // super("Unknown command: " + command); // } // // private static final long serialVersionUID = 1L; // } // // Path: public-java/robots/iamcontent-robotic-arm-edge/src/main/java/com/iamcontent/robot/arm/edge/RoboticEdgeArm.java // public enum Command { // GRIPPER_CLOSE(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_FORWARD), // GRIPPER_OPEN(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_BACKWARD), // GRIPPER_STOP(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_STOP), // // WRIST_EXTEND(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_FORWARD), // WRIST_FLEX(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_BACKWARD), // WRIST_STOP(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_STOP), // // ELBOW_EXTEND(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_FORWARD), // ELBOW_FLEX(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_BACKWARD), // ELBOW_STOP(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_STOP), // // SHOULDER_BACKWARD(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_FORWARD), // SHOULDER_FORWARD(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_BACKWARD), // SHOULDER_STOP(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_STOP), // // BASE_RIGHT(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_FORWARD), // BASE_LEFT(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_BACKWARD), // BASE_STOP(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_STOP), // // LED_ON(Actuator.LED, Owi535UsbMotorController.Command.LED_ON), // LED_OFF(Actuator.LED, Owi535UsbMotorController.Command.LED_OFF); // // final Actuator actuator; // final Owi535UsbMotorController.Command controllerCommand; // // private Command(Actuator actuator, Owi535UsbMotorController.Command controllerCommand) { // this.actuator = actuator; // this.controllerCommand = controllerCommand; // } // public Actuator getActuator() { // return actuator; // } // public Owi535UsbMotorController.Command getControllerCommand() { // return controllerCommand; // } // }; // Path: public-java/robots/iamcontent-robotic-arm-edge/src/main/java/com/iamcontent/robot/arm/edge/ParseStringIntoCommandFunction.java import com.iamcontent.robot.arm.edge.RoboticEdgeArm.Command; import static com.iamcontent.io.cli.CommandLineDriver.tidied; import java.util.function.Function; import com.iamcontent.io.cli.UnknownCommandException; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.arm.edge; /** * A function to parse a String command into a {@link Command}. */ public class ParseStringIntoCommandFunction implements Function<String, Command> { @Override public Command apply(String command) {
switch (tidied(command)) {
IAmContent/public
public-java/robots/iamcontent-robotic-arm-edge/src/main/java/com/iamcontent/robot/arm/edge/ParseStringIntoCommandFunction.java
// Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/CommandLineDriver.java // public static String tidied(String command) { // return command.trim().toLowerCase(); // } // // Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/UnknownCommandException.java // public class UnknownCommandException extends RuntimeException { // public UnknownCommandException(String command) { // super("Unknown command: " + command); // } // // private static final long serialVersionUID = 1L; // } // // Path: public-java/robots/iamcontent-robotic-arm-edge/src/main/java/com/iamcontent/robot/arm/edge/RoboticEdgeArm.java // public enum Command { // GRIPPER_CLOSE(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_FORWARD), // GRIPPER_OPEN(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_BACKWARD), // GRIPPER_STOP(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_STOP), // // WRIST_EXTEND(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_FORWARD), // WRIST_FLEX(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_BACKWARD), // WRIST_STOP(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_STOP), // // ELBOW_EXTEND(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_FORWARD), // ELBOW_FLEX(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_BACKWARD), // ELBOW_STOP(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_STOP), // // SHOULDER_BACKWARD(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_FORWARD), // SHOULDER_FORWARD(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_BACKWARD), // SHOULDER_STOP(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_STOP), // // BASE_RIGHT(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_FORWARD), // BASE_LEFT(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_BACKWARD), // BASE_STOP(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_STOP), // // LED_ON(Actuator.LED, Owi535UsbMotorController.Command.LED_ON), // LED_OFF(Actuator.LED, Owi535UsbMotorController.Command.LED_OFF); // // final Actuator actuator; // final Owi535UsbMotorController.Command controllerCommand; // // private Command(Actuator actuator, Owi535UsbMotorController.Command controllerCommand) { // this.actuator = actuator; // this.controllerCommand = controllerCommand; // } // public Actuator getActuator() { // return actuator; // } // public Owi535UsbMotorController.Command getControllerCommand() { // return controllerCommand; // } // };
import com.iamcontent.robot.arm.edge.RoboticEdgeArm.Command; import static com.iamcontent.io.cli.CommandLineDriver.tidied; import java.util.function.Function; import com.iamcontent.io.cli.UnknownCommandException;
return Command.WRIST_STOP; case "grip open": case "gripper open": case "go": return Command.GRIPPER_OPEN; case "grip close": case "gripper close": case "gc": return Command.GRIPPER_CLOSE; case "grip stop": case "gripper stop": case "gs": return Command.GRIPPER_STOP; case "led on": case "light on": case "l+": return Command.LED_ON; case "led off": case "light off": case "l-": return Command.LED_OFF; case "stop": case "": return null; default:
// Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/CommandLineDriver.java // public static String tidied(String command) { // return command.trim().toLowerCase(); // } // // Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/UnknownCommandException.java // public class UnknownCommandException extends RuntimeException { // public UnknownCommandException(String command) { // super("Unknown command: " + command); // } // // private static final long serialVersionUID = 1L; // } // // Path: public-java/robots/iamcontent-robotic-arm-edge/src/main/java/com/iamcontent/robot/arm/edge/RoboticEdgeArm.java // public enum Command { // GRIPPER_CLOSE(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_FORWARD), // GRIPPER_OPEN(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_BACKWARD), // GRIPPER_STOP(Actuator.GRIPPER, Owi535UsbMotorController.Command.MOTOR_1_STOP), // // WRIST_EXTEND(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_FORWARD), // WRIST_FLEX(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_BACKWARD), // WRIST_STOP(Actuator.WRIST, Owi535UsbMotorController.Command.MOTOR_2_STOP), // // ELBOW_EXTEND(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_FORWARD), // ELBOW_FLEX(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_BACKWARD), // ELBOW_STOP(Actuator.ELBOW, Owi535UsbMotorController.Command.MOTOR_3_STOP), // // SHOULDER_BACKWARD(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_FORWARD), // SHOULDER_FORWARD(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_BACKWARD), // SHOULDER_STOP(Actuator.SHOULDER, Owi535UsbMotorController.Command.MOTOR_4_STOP), // // BASE_RIGHT(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_FORWARD), // BASE_LEFT(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_BACKWARD), // BASE_STOP(Actuator.BASE, Owi535UsbMotorController.Command.MOTOR_5_STOP), // // LED_ON(Actuator.LED, Owi535UsbMotorController.Command.LED_ON), // LED_OFF(Actuator.LED, Owi535UsbMotorController.Command.LED_OFF); // // final Actuator actuator; // final Owi535UsbMotorController.Command controllerCommand; // // private Command(Actuator actuator, Owi535UsbMotorController.Command controllerCommand) { // this.actuator = actuator; // this.controllerCommand = controllerCommand; // } // public Actuator getActuator() { // return actuator; // } // public Owi535UsbMotorController.Command getControllerCommand() { // return controllerCommand; // } // }; // Path: public-java/robots/iamcontent-robotic-arm-edge/src/main/java/com/iamcontent/robot/arm/edge/ParseStringIntoCommandFunction.java import com.iamcontent.robot.arm.edge.RoboticEdgeArm.Command; import static com.iamcontent.io.cli.CommandLineDriver.tidied; import java.util.function.Function; import com.iamcontent.io.cli.UnknownCommandException; return Command.WRIST_STOP; case "grip open": case "gripper open": case "go": return Command.GRIPPER_OPEN; case "grip close": case "gripper close": case "gc": return Command.GRIPPER_CLOSE; case "grip stop": case "gripper stop": case "gs": return Command.GRIPPER_STOP; case "led on": case "light on": case "l+": return Command.LED_ON; case "led off": case "light off": case "l-": return Command.LED_OFF; case "stop": case "": return null; default:
throw new UnknownCommandException(command);
IAmContent/public
public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIOSource.java // public class CalibratedAnalogIOSource<C> extends Delegator<AnalogIOSource<C>> implements AnalogIOSource<C> { // // private final AnalogIOSourceCalibration<C> calibration; // // public CalibratedAnalogIOSource(AnalogIOSource<C> target, AnalogIOSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public AnalogIO forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // // protected AnalogIOSourceCalibration<C> calibration() { // return calibration; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RawAnalogIO.java // public class RawAnalogIO<C> implements AnalogIO { // // protected final AnalogIOController<C> controller; // protected final C channelId; // // public RawAnalogIO(AnalogIOController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RemappedAnalogIOSource.java // public class RemappedAnalogIOSource<NewChannelId, DelegateChannelId> extends Delegator<AnalogIOSource<DelegateChannelId>> implements AnalogIOSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedAnalogIOSource(AnalogIOSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public AnalogIO forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // }
import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.io.analog.impl.CalibratedAnalogIOSource; import com.iamcontent.device.io.analog.impl.RawAnalogIO; import com.iamcontent.device.io.analog.impl.RemappedAnalogIOSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog; /** * Represents a source of {@link AnalogIO}s. * @author Greg Elderfield * * @param <C> The type used to identify an analog input/output channel. */ public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { /** * Returns a AnalogIOSource that has new channel ids, as defined by the given function. */ default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) {
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIOSource.java // public class CalibratedAnalogIOSource<C> extends Delegator<AnalogIOSource<C>> implements AnalogIOSource<C> { // // private final AnalogIOSourceCalibration<C> calibration; // // public CalibratedAnalogIOSource(AnalogIOSource<C> target, AnalogIOSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public AnalogIO forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // // protected AnalogIOSourceCalibration<C> calibration() { // return calibration; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RawAnalogIO.java // public class RawAnalogIO<C> implements AnalogIO { // // protected final AnalogIOController<C> controller; // protected final C channelId; // // public RawAnalogIO(AnalogIOController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RemappedAnalogIOSource.java // public class RemappedAnalogIOSource<NewChannelId, DelegateChannelId> extends Delegator<AnalogIOSource<DelegateChannelId>> implements AnalogIOSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedAnalogIOSource(AnalogIOSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public AnalogIO forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // } // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.io.analog.impl.CalibratedAnalogIOSource; import com.iamcontent.device.io.analog.impl.RawAnalogIO; import com.iamcontent.device.io.analog.impl.RemappedAnalogIOSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog; /** * Represents a source of {@link AnalogIO}s. * @author Greg Elderfield * * @param <C> The type used to identify an analog input/output channel. */ public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { /** * Returns a AnalogIOSource that has new channel ids, as defined by the given function. */ default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) {
return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping);
IAmContent/public
public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIOSource.java // public class CalibratedAnalogIOSource<C> extends Delegator<AnalogIOSource<C>> implements AnalogIOSource<C> { // // private final AnalogIOSourceCalibration<C> calibration; // // public CalibratedAnalogIOSource(AnalogIOSource<C> target, AnalogIOSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public AnalogIO forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // // protected AnalogIOSourceCalibration<C> calibration() { // return calibration; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RawAnalogIO.java // public class RawAnalogIO<C> implements AnalogIO { // // protected final AnalogIOController<C> controller; // protected final C channelId; // // public RawAnalogIO(AnalogIOController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RemappedAnalogIOSource.java // public class RemappedAnalogIOSource<NewChannelId, DelegateChannelId> extends Delegator<AnalogIOSource<DelegateChannelId>> implements AnalogIOSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedAnalogIOSource(AnalogIOSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public AnalogIO forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // }
import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.io.analog.impl.CalibratedAnalogIOSource; import com.iamcontent.device.io.analog.impl.RawAnalogIO; import com.iamcontent.device.io.analog.impl.RemappedAnalogIOSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog; /** * Represents a source of {@link AnalogIO}s. * @author Greg Elderfield * * @param <C> The type used to identify an analog input/output channel. */ public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { /** * Returns a AnalogIOSource that has new channel ids, as defined by the given function. */ default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); } /** * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. */ default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) {
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIOSource.java // public class CalibratedAnalogIOSource<C> extends Delegator<AnalogIOSource<C>> implements AnalogIOSource<C> { // // private final AnalogIOSourceCalibration<C> calibration; // // public CalibratedAnalogIOSource(AnalogIOSource<C> target, AnalogIOSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public AnalogIO forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // // protected AnalogIOSourceCalibration<C> calibration() { // return calibration; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RawAnalogIO.java // public class RawAnalogIO<C> implements AnalogIO { // // protected final AnalogIOController<C> controller; // protected final C channelId; // // public RawAnalogIO(AnalogIOController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RemappedAnalogIOSource.java // public class RemappedAnalogIOSource<NewChannelId, DelegateChannelId> extends Delegator<AnalogIOSource<DelegateChannelId>> implements AnalogIOSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedAnalogIOSource(AnalogIOSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public AnalogIO forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // } // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.io.analog.impl.CalibratedAnalogIOSource; import com.iamcontent.device.io.analog.impl.RawAnalogIO; import com.iamcontent.device.io.analog.impl.RemappedAnalogIOSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog; /** * Represents a source of {@link AnalogIO}s. * @author Greg Elderfield * * @param <C> The type used to identify an analog input/output channel. */ public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { /** * Returns a AnalogIOSource that has new channel ids, as defined by the given function. */ default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); } /** * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. */ default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) {
return new CalibratedAnalogIOSource<C>(this, calibration);
IAmContent/public
public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIOSource.java // public class CalibratedAnalogIOSource<C> extends Delegator<AnalogIOSource<C>> implements AnalogIOSource<C> { // // private final AnalogIOSourceCalibration<C> calibration; // // public CalibratedAnalogIOSource(AnalogIOSource<C> target, AnalogIOSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public AnalogIO forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // // protected AnalogIOSourceCalibration<C> calibration() { // return calibration; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RawAnalogIO.java // public class RawAnalogIO<C> implements AnalogIO { // // protected final AnalogIOController<C> controller; // protected final C channelId; // // public RawAnalogIO(AnalogIOController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RemappedAnalogIOSource.java // public class RemappedAnalogIOSource<NewChannelId, DelegateChannelId> extends Delegator<AnalogIOSource<DelegateChannelId>> implements AnalogIOSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedAnalogIOSource(AnalogIOSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public AnalogIO forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // }
import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.io.analog.impl.CalibratedAnalogIOSource; import com.iamcontent.device.io.analog.impl.RawAnalogIO; import com.iamcontent.device.io.analog.impl.RemappedAnalogIOSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog; /** * Represents a source of {@link AnalogIO}s. * @author Greg Elderfield * * @param <C> The type used to identify an analog input/output channel. */ public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { /** * Returns a AnalogIOSource that has new channel ids, as defined by the given function. */ default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); } /** * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. */ default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { return new CalibratedAnalogIOSource<C>(this, calibration); } public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { return new AnalogIOSource<C>() { @Override public AnalogIO forChannel(C channelId) {
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java // public interface PerChannelSource<C, T> { // T forChannel(C channelId); // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIOSource.java // public class CalibratedAnalogIOSource<C> extends Delegator<AnalogIOSource<C>> implements AnalogIOSource<C> { // // private final AnalogIOSourceCalibration<C> calibration; // // public CalibratedAnalogIOSource(AnalogIOSource<C> target, AnalogIOSourceCalibration<C> calibration) { // super(target); // this.calibration = calibration; // } // // @Override // public AnalogIO forChannel(C channelId) { // return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId)); // } // // protected AnalogIOSourceCalibration<C> calibration() { // return calibration; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RawAnalogIO.java // public class RawAnalogIO<C> implements AnalogIO { // // protected final AnalogIOController<C> controller; // protected final C channelId; // // public RawAnalogIO(AnalogIOController<C> controller, C channelId) { // this.controller = controller; // this.channelId = channelId; // } // // @Override // public MutableDouble value() { // return controller.value(channelId); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RemappedAnalogIOSource.java // public class RemappedAnalogIOSource<NewChannelId, DelegateChannelId> extends Delegator<AnalogIOSource<DelegateChannelId>> implements AnalogIOSource<NewChannelId> { // // protected final Function<NewChannelId, DelegateChannelId> remapping; // // public RemappedAnalogIOSource(AnalogIOSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { // super(target); // this.remapping = remapping; // } // // @Override // public AnalogIO forChannel(NewChannelId channelId) { // return delegate().forChannel(remapping.apply(channelId)); // } // } // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java import java.util.function.Function; import com.iamcontent.device.channel.PerChannelSource; import com.iamcontent.device.io.analog.impl.CalibratedAnalogIOSource; import com.iamcontent.device.io.analog.impl.RawAnalogIO; import com.iamcontent.device.io.analog.impl.RemappedAnalogIOSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog; /** * Represents a source of {@link AnalogIO}s. * @author Greg Elderfield * * @param <C> The type used to identify an analog input/output channel. */ public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { /** * Returns a AnalogIOSource that has new channel ids, as defined by the given function. */ default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); } /** * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. */ default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { return new CalibratedAnalogIOSource<C>(this, calibration); } public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { return new AnalogIOSource<C>() { @Override public AnalogIO forChannel(C channelId) {
return new RawAnalogIO<C>(controller, channelId);
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbMaestroCardType.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static boolean vendorAndProductIdsMatch(short vendorId, short productId, UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device.getUsbDeviceDescriptor()); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbRuntimeException.java // public class UsbRuntimeException extends RuntimeException { // public UsbRuntimeException(String message) { // super(message); // } // // public UsbRuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MICRO_MAESTRO_6; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_12; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_18; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_24; import static com.iamcontent.io.usb.UsbDevicePredicates.vendorAndProductIdsMatch; import java.util.Optional; import java.util.stream.Stream; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; import com.iamcontent.io.usb.UsbRuntimeException;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * The USB characteristics of the different types of Pololu Maestro cards. * * The id values used by this protocol were obtained from Pololu's Native USB SDK, * downloaded from www.pololu.com. * * @author Greg Elderfield */ public enum UsbMaestroCardType { USB_MICRO_MAESTRO_6(MICRO_MAESTRO_6, 0x0089), USB_MINI_MAESTRO_12(MINI_MAESTRO_12, 0x008A), USB_MINI_MAESTRO_18(MINI_MAESTRO_18, 0x008B), USB_MINI_MAESTRO_24(MINI_MAESTRO_24, 0x008C); public static final short VENDOR_ID = 0x1ffb;
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static boolean vendorAndProductIdsMatch(short vendorId, short productId, UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device.getUsbDeviceDescriptor()); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbRuntimeException.java // public class UsbRuntimeException extends RuntimeException { // public UsbRuntimeException(String message) { // super(message); // } // // public UsbRuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbMaestroCardType.java import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MICRO_MAESTRO_6; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_12; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_18; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_24; import static com.iamcontent.io.usb.UsbDevicePredicates.vendorAndProductIdsMatch; import java.util.Optional; import java.util.stream.Stream; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; import com.iamcontent.io.usb.UsbRuntimeException; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * The USB characteristics of the different types of Pololu Maestro cards. * * The id values used by this protocol were obtained from Pololu's Native USB SDK, * downloaded from www.pololu.com. * * @author Greg Elderfield */ public enum UsbMaestroCardType { USB_MICRO_MAESTRO_6(MICRO_MAESTRO_6, 0x0089), USB_MINI_MAESTRO_12(MINI_MAESTRO_12, 0x008A), USB_MINI_MAESTRO_18(MINI_MAESTRO_18, 0x008B), USB_MINI_MAESTRO_24(MINI_MAESTRO_24, 0x008C); public static final short VENDOR_ID = 0x1ffb;
private final MaestroCardType type;
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbMaestroCardType.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static boolean vendorAndProductIdsMatch(short vendorId, short productId, UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device.getUsbDeviceDescriptor()); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbRuntimeException.java // public class UsbRuntimeException extends RuntimeException { // public UsbRuntimeException(String message) { // super(message); // } // // public UsbRuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MICRO_MAESTRO_6; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_12; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_18; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_24; import static com.iamcontent.io.usb.UsbDevicePredicates.vendorAndProductIdsMatch; import java.util.Optional; import java.util.stream.Stream; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; import com.iamcontent.io.usb.UsbRuntimeException;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * The USB characteristics of the different types of Pololu Maestro cards. * * The id values used by this protocol were obtained from Pololu's Native USB SDK, * downloaded from www.pololu.com. * * @author Greg Elderfield */ public enum UsbMaestroCardType { USB_MICRO_MAESTRO_6(MICRO_MAESTRO_6, 0x0089), USB_MINI_MAESTRO_12(MINI_MAESTRO_12, 0x008A), USB_MINI_MAESTRO_18(MINI_MAESTRO_18, 0x008B), USB_MINI_MAESTRO_24(MINI_MAESTRO_24, 0x008C); public static final short VENDOR_ID = 0x1ffb; private final MaestroCardType type; private final short productId; private UsbMaestroCardType(MaestroCardType type, int productId) { this.type = type; this.productId = (short)productId; } public MaestroCardType getType() { return type; } public short getProductId() { return productId; } public static UsbMaestroCardType cardTypeForUsbDeviceOrThrow(UsbDevice device) {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static boolean vendorAndProductIdsMatch(short vendorId, short productId, UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device.getUsbDeviceDescriptor()); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbRuntimeException.java // public class UsbRuntimeException extends RuntimeException { // public UsbRuntimeException(String message) { // super(message); // } // // public UsbRuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbMaestroCardType.java import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MICRO_MAESTRO_6; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_12; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_18; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_24; import static com.iamcontent.io.usb.UsbDevicePredicates.vendorAndProductIdsMatch; import java.util.Optional; import java.util.stream.Stream; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; import com.iamcontent.io.usb.UsbRuntimeException; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * The USB characteristics of the different types of Pololu Maestro cards. * * The id values used by this protocol were obtained from Pololu's Native USB SDK, * downloaded from www.pololu.com. * * @author Greg Elderfield */ public enum UsbMaestroCardType { USB_MICRO_MAESTRO_6(MICRO_MAESTRO_6, 0x0089), USB_MINI_MAESTRO_12(MINI_MAESTRO_12, 0x008A), USB_MINI_MAESTRO_18(MINI_MAESTRO_18, 0x008B), USB_MINI_MAESTRO_24(MINI_MAESTRO_24, 0x008C); public static final short VENDOR_ID = 0x1ffb; private final MaestroCardType type; private final short productId; private UsbMaestroCardType(MaestroCardType type, int productId) { this.type = type; this.productId = (short)productId; } public MaestroCardType getType() { return type; } public short getProductId() { return productId; } public static UsbMaestroCardType cardTypeForUsbDeviceOrThrow(UsbDevice device) {
return cardTypeForUsbDevice(device).orElseThrow(() -> new UsbRuntimeException("USB Device is not a Usb Maestro Card"));
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbMaestroCardType.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static boolean vendorAndProductIdsMatch(short vendorId, short productId, UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device.getUsbDeviceDescriptor()); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbRuntimeException.java // public class UsbRuntimeException extends RuntimeException { // public UsbRuntimeException(String message) { // super(message); // } // // public UsbRuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MICRO_MAESTRO_6; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_12; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_18; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_24; import static com.iamcontent.io.usb.UsbDevicePredicates.vendorAndProductIdsMatch; import java.util.Optional; import java.util.stream.Stream; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; import com.iamcontent.io.usb.UsbRuntimeException;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * The USB characteristics of the different types of Pololu Maestro cards. * * The id values used by this protocol were obtained from Pololu's Native USB SDK, * downloaded from www.pololu.com. * * @author Greg Elderfield */ public enum UsbMaestroCardType { USB_MICRO_MAESTRO_6(MICRO_MAESTRO_6, 0x0089), USB_MINI_MAESTRO_12(MINI_MAESTRO_12, 0x008A), USB_MINI_MAESTRO_18(MINI_MAESTRO_18, 0x008B), USB_MINI_MAESTRO_24(MINI_MAESTRO_24, 0x008C); public static final short VENDOR_ID = 0x1ffb; private final MaestroCardType type; private final short productId; private UsbMaestroCardType(MaestroCardType type, int productId) { this.type = type; this.productId = (short)productId; } public MaestroCardType getType() { return type; } public short getProductId() { return productId; } public static UsbMaestroCardType cardTypeForUsbDeviceOrThrow(UsbDevice device) { return cardTypeForUsbDevice(device).orElseThrow(() -> new UsbRuntimeException("USB Device is not a Usb Maestro Card")); } public static boolean isAMaestroCard(UsbDevice device) { return cardTypeForUsbDevice(device).isPresent(); } public static Optional<UsbMaestroCardType> cardTypeForUsbDevice(UsbDevice device) {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static boolean vendorAndProductIdsMatch(short vendorId, short productId, UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device.getUsbDeviceDescriptor()); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/MaestroCardType.java // public enum MaestroCardType { // // MICRO_MAESTRO_6(6), // MINI_MAESTRO_12(12), // MINI_MAESTRO_18(18), // MINI_MAESTRO_24(24); // // private final int channelCount; // // private MaestroCardType(int channelCount) { // this.channelCount = channelCount; // } // // public int channelCount() { // return channelCount; // } // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbRuntimeException.java // public class UsbRuntimeException extends RuntimeException { // public UsbRuntimeException(String message) { // super(message); // } // // public UsbRuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbMaestroCardType.java import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MICRO_MAESTRO_6; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_12; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_18; import static com.iamcontent.device.controller.pololu.maestro.MaestroCardType.MINI_MAESTRO_24; import static com.iamcontent.io.usb.UsbDevicePredicates.vendorAndProductIdsMatch; import java.util.Optional; import java.util.stream.Stream; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.MaestroCardType; import com.iamcontent.io.usb.UsbRuntimeException; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * The USB characteristics of the different types of Pololu Maestro cards. * * The id values used by this protocol were obtained from Pololu's Native USB SDK, * downloaded from www.pololu.com. * * @author Greg Elderfield */ public enum UsbMaestroCardType { USB_MICRO_MAESTRO_6(MICRO_MAESTRO_6, 0x0089), USB_MINI_MAESTRO_12(MINI_MAESTRO_12, 0x008A), USB_MINI_MAESTRO_18(MINI_MAESTRO_18, 0x008B), USB_MINI_MAESTRO_24(MINI_MAESTRO_24, 0x008C); public static final short VENDOR_ID = 0x1ffb; private final MaestroCardType type; private final short productId; private UsbMaestroCardType(MaestroCardType type, int productId) { this.type = type; this.productId = (short)productId; } public MaestroCardType getType() { return type; } public short getProductId() { return productId; } public static UsbMaestroCardType cardTypeForUsbDeviceOrThrow(UsbDevice device) { return cardTypeForUsbDevice(device).orElseThrow(() -> new UsbRuntimeException("USB Device is not a Usb Maestro Card")); } public static boolean isAMaestroCard(UsbDevice device) { return cardTypeForUsbDevice(device).isPresent(); } public static Optional<UsbMaestroCardType> cardTypeForUsbDevice(UsbDevice device) {
return Stream.of(values()).filter(c -> vendorAndProductIdsMatch(VENDOR_ID, c.getProductId(), device)).findFirst();
IAmContent/public
public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbTopologyTreePrinter.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/license/License.java // public static void displayLicense() { // for (String s : MINIMAL_TERMS) // System.out.println(s); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbRuntimeException.java // public class UsbRuntimeException extends RuntimeException { // public UsbRuntimeException(String message) { // super(message); // } // // public UsbRuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import static com.iamcontent.io.usb.license.License.displayLicense; import java.io.IOException; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHub; import com.iamcontent.io.usb.UsbRuntimeException;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb.topology; /** * Prints the USB topology tree from the root hub downwards. * @author Greg Elderfield */ public class UsbTopologyTreePrinter extends UsbTopologyExplorer { private static final Predicate<UsbDevice> VISIT_ALL_DEVICES = x -> true; private static final String TAB = " "; private static final StringBuilder padding = new StringBuilder(); private final Appendable out; public UsbTopologyTreePrinter() { this(VISIT_ALL_DEVICES, System.out); } public UsbTopologyTreePrinter(Predicate<UsbDevice> shouldVisit, Appendable out) { super(shouldVisit); this.out = out; } public static void main(String[] args) {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/license/License.java // public static void displayLicense() { // for (String s : MINIMAL_TERMS) // System.out.println(s); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbRuntimeException.java // public class UsbRuntimeException extends RuntimeException { // public UsbRuntimeException(String message) { // super(message); // } // // public UsbRuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbTopologyTreePrinter.java import static com.iamcontent.io.usb.license.License.displayLicense; import java.io.IOException; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHub; import com.iamcontent.io.usb.UsbRuntimeException; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb.topology; /** * Prints the USB topology tree from the root hub downwards. * @author Greg Elderfield */ public class UsbTopologyTreePrinter extends UsbTopologyExplorer { private static final Predicate<UsbDevice> VISIT_ALL_DEVICES = x -> true; private static final String TAB = " "; private static final StringBuilder padding = new StringBuilder(); private final Appendable out; public UsbTopologyTreePrinter() { this(VISIT_ALL_DEVICES, System.out); } public UsbTopologyTreePrinter(Predicate<UsbDevice> shouldVisit, Appendable out) { super(shouldVisit); this.out = out; } public static void main(String[] args) {
displayLicense();
IAmContent/public
public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbTopologyTreePrinter.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/license/License.java // public static void displayLicense() { // for (String s : MINIMAL_TERMS) // System.out.println(s); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbRuntimeException.java // public class UsbRuntimeException extends RuntimeException { // public UsbRuntimeException(String message) { // super(message); // } // // public UsbRuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import static com.iamcontent.io.usb.license.License.displayLicense; import java.io.IOException; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHub; import com.iamcontent.io.usb.UsbRuntimeException;
this(VISIT_ALL_DEVICES, System.out); } public UsbTopologyTreePrinter(Predicate<UsbDevice> shouldVisit, Appendable out) { super(shouldVisit); this.out = out; } public static void main(String[] args) { displayLicense(); final UsbTopologyTreePrinter printer = new UsbTopologyTreePrinter(); printer.exploreRootUsbHub(); } @Override protected void exploreDescendants(UsbHub hub) { increasePadding(); super.exploreDescendants(hub); decreasePadding(); } @Override public void visit(UsbDevice usbDevice) { appendQuietly(out, padding + usbDevice.toString() + "\n"); } public static void appendQuietly(Appendable out, String s) { try { out.append(s); } catch (IOException e) {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/license/License.java // public static void displayLicense() { // for (String s : MINIMAL_TERMS) // System.out.println(s); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbRuntimeException.java // public class UsbRuntimeException extends RuntimeException { // public UsbRuntimeException(String message) { // super(message); // } // // public UsbRuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbTopologyTreePrinter.java import static com.iamcontent.io.usb.license.License.displayLicense; import java.io.IOException; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHub; import com.iamcontent.io.usb.UsbRuntimeException; this(VISIT_ALL_DEVICES, System.out); } public UsbTopologyTreePrinter(Predicate<UsbDevice> shouldVisit, Appendable out) { super(shouldVisit); this.out = out; } public static void main(String[] args) { displayLicense(); final UsbTopologyTreePrinter printer = new UsbTopologyTreePrinter(); printer.exploreRootUsbHub(); } @Override protected void exploreDescendants(UsbHub hub) { increasePadding(); super.exploreDescendants(hub); decreasePadding(); } @Override public void visit(UsbDevice usbDevice) { appendQuietly(out, padding + usbDevice.toString() + "\n"); } public static void appendQuietly(Appendable out, String s) { try { out.append(s); } catch (IOException e) {
throw new UsbRuntimeException(e);
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // }
import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1; /** * Represents a Robonova biped robot. * @author Greg Elderfield */ public interface Robonova { ServoSource<ServoId> servos();
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1; /** * Represents a Robonova biped robot. * @author Greg Elderfield */ public interface Robonova { ServoSource<ServoId> servos();
AnalogIOSource<ThreeDimension> accelerometer();
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // }
import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1; /** * Represents a Robonova biped robot. * @author Greg Elderfield */ public interface Robonova { ServoSource<ServoId> servos();
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.servo.ServoSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1; /** * Represents a Robonova biped robot. * @author Greg Elderfield */ public interface Robonova { ServoSource<ServoId> servos();
AnalogIOSource<ThreeDimension> accelerometer();
IAmContent/public
public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/ResourceUtils.java
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static void appendQuietly(Appendable out, String s) { // try { // out.append(s); // } catch (IOException e) { // throw new IORuntimeException(e); // } // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static Stream<String> lineStreamOf(InputStream is) { // final InputStreamReader reader = new InputStreamReader(is); // return new BufferedReader(reader).lines(); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import static com.iamcontent.io.util.IOUtils.appendQuietly; import static com.iamcontent.io.util.IOUtils.lineStreamOf; import java.io.InputStream; import java.util.stream.Stream; import com.iamcontent.io.IORuntimeException;
package com.iamcontent.io.util; /** * Utilities for reading resources. * @author Greg Elderfield */ public class ResourceUtils { public static void appendResource(String fileName, Appendable onto) {
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static void appendQuietly(Appendable out, String s) { // try { // out.append(s); // } catch (IOException e) { // throw new IORuntimeException(e); // } // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static Stream<String> lineStreamOf(InputStream is) { // final InputStreamReader reader = new InputStreamReader(is); // return new BufferedReader(reader).lines(); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/ResourceUtils.java import static com.iamcontent.io.util.IOUtils.appendQuietly; import static com.iamcontent.io.util.IOUtils.lineStreamOf; import java.io.InputStream; import java.util.stream.Stream; import com.iamcontent.io.IORuntimeException; package com.iamcontent.io.util; /** * Utilities for reading resources. * @author Greg Elderfield */ public class ResourceUtils { public static void appendResource(String fileName, Appendable onto) {
resourceAsLineStream(fileName).forEach(l -> appendQuietly(onto, l));
IAmContent/public
public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/ResourceUtils.java
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static void appendQuietly(Appendable out, String s) { // try { // out.append(s); // } catch (IOException e) { // throw new IORuntimeException(e); // } // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static Stream<String> lineStreamOf(InputStream is) { // final InputStreamReader reader = new InputStreamReader(is); // return new BufferedReader(reader).lines(); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import static com.iamcontent.io.util.IOUtils.appendQuietly; import static com.iamcontent.io.util.IOUtils.lineStreamOf; import java.io.InputStream; import java.util.stream.Stream; import com.iamcontent.io.IORuntimeException;
package com.iamcontent.io.util; /** * Utilities for reading resources. * @author Greg Elderfield */ public class ResourceUtils { public static void appendResource(String fileName, Appendable onto) { resourceAsLineStream(fileName).forEach(l -> appendQuietly(onto, l)); } public static Stream<String> resourceAsLineStream(String fileName) { final InputStream is = ResourceUtils.class.getClassLoader().getResourceAsStream(fileName); if (is==null)
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static void appendQuietly(Appendable out, String s) { // try { // out.append(s); // } catch (IOException e) { // throw new IORuntimeException(e); // } // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static Stream<String> lineStreamOf(InputStream is) { // final InputStreamReader reader = new InputStreamReader(is); // return new BufferedReader(reader).lines(); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/ResourceUtils.java import static com.iamcontent.io.util.IOUtils.appendQuietly; import static com.iamcontent.io.util.IOUtils.lineStreamOf; import java.io.InputStream; import java.util.stream.Stream; import com.iamcontent.io.IORuntimeException; package com.iamcontent.io.util; /** * Utilities for reading resources. * @author Greg Elderfield */ public class ResourceUtils { public static void appendResource(String fileName, Appendable onto) { resourceAsLineStream(fileName).forEach(l -> appendQuietly(onto, l)); } public static Stream<String> resourceAsLineStream(String fileName) { final InputStream is = ResourceUtils.class.getClassLoader().getResourceAsStream(fileName); if (is==null)
throw new IORuntimeException("Could not find resource: " + fileName);
IAmContent/public
public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/ResourceUtils.java
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static void appendQuietly(Appendable out, String s) { // try { // out.append(s); // } catch (IOException e) { // throw new IORuntimeException(e); // } // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static Stream<String> lineStreamOf(InputStream is) { // final InputStreamReader reader = new InputStreamReader(is); // return new BufferedReader(reader).lines(); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import static com.iamcontent.io.util.IOUtils.appendQuietly; import static com.iamcontent.io.util.IOUtils.lineStreamOf; import java.io.InputStream; import java.util.stream.Stream; import com.iamcontent.io.IORuntimeException;
package com.iamcontent.io.util; /** * Utilities for reading resources. * @author Greg Elderfield */ public class ResourceUtils { public static void appendResource(String fileName, Appendable onto) { resourceAsLineStream(fileName).forEach(l -> appendQuietly(onto, l)); } public static Stream<String> resourceAsLineStream(String fileName) { final InputStream is = ResourceUtils.class.getClassLoader().getResourceAsStream(fileName); if (is==null) throw new IORuntimeException("Could not find resource: " + fileName);
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static void appendQuietly(Appendable out, String s) { // try { // out.append(s); // } catch (IOException e) { // throw new IORuntimeException(e); // } // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/IOUtils.java // public static Stream<String> lineStreamOf(InputStream is) { // final InputStreamReader reader = new InputStreamReader(is); // return new BufferedReader(reader).lines(); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/ResourceUtils.java import static com.iamcontent.io.util.IOUtils.appendQuietly; import static com.iamcontent.io.util.IOUtils.lineStreamOf; import java.io.InputStream; import java.util.stream.Stream; import com.iamcontent.io.IORuntimeException; package com.iamcontent.io.util; /** * Utilities for reading resources. * @author Greg Elderfield */ public class ResourceUtils { public static void appendResource(String fileName, Appendable onto) { resourceAsLineStream(fileName).forEach(l -> appendQuietly(onto, l)); } public static Stream<String> resourceAsLineStream(String fileName) { final InputStream is = ResourceUtils.class.getClassLoader().getResourceAsStream(fileName); if (is==null) throw new IORuntimeException("Could not find resource: " + fileName);
return lineStreamOf(is);
IAmContent/public
public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RemappedAnalogIOSource.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/lang/Delegator.java // public abstract class Delegator<D> { // private final D delegate; // // public Delegator(D delegate) { // requireNonNull(delegate, "Delegate cannot be null."); // this.delegate = delegate; // } // // protected D delegate() { // return delegate; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java // public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIO calibrated(AnalogIOCalibration calibration) { // return new CalibratedAnalogIO(this, calibration); // } // // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // }
import java.util.function.Function; import com.iamcontent.core.lang.Delegator; import com.iamcontent.device.io.analog.AnalogIO; import com.iamcontent.device.io.analog.AnalogIOSource;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog.impl; /** * A {@link AnalogIOSource} that has new channel ids, as defined by a mapping function. * * @author Greg Elderfield */ public class RemappedAnalogIOSource<NewChannelId, DelegateChannelId> extends Delegator<AnalogIOSource<DelegateChannelId>> implements AnalogIOSource<NewChannelId> { protected final Function<NewChannelId, DelegateChannelId> remapping; public RemappedAnalogIOSource(AnalogIOSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { super(target); this.remapping = remapping; } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/lang/Delegator.java // public abstract class Delegator<D> { // private final D delegate; // // public Delegator(D delegate) { // requireNonNull(delegate, "Delegate cannot be null."); // this.delegate = delegate; // } // // protected D delegate() { // return delegate; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java // public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIO calibrated(AnalogIOCalibration calibration) { // return new CalibratedAnalogIO(this, calibration); // } // // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RemappedAnalogIOSource.java import java.util.function.Function; import com.iamcontent.core.lang.Delegator; import com.iamcontent.device.io.analog.AnalogIO; import com.iamcontent.device.io.analog.AnalogIOSource; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.io.analog.impl; /** * A {@link AnalogIOSource} that has new channel ids, as defined by a mapping function. * * @author Greg Elderfield */ public class RemappedAnalogIOSource<NewChannelId, DelegateChannelId> extends Delegator<AnalogIOSource<DelegateChannelId>> implements AnalogIOSource<NewChannelId> { protected final Function<NewChannelId, DelegateChannelId> remapping; public RemappedAnalogIOSource(AnalogIOSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) { super(target); this.remapping = remapping; } @Override
public AnalogIO forChannel(NewChannelId channelId) {
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/command/ParseStringIntoServoCommand.java
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/UnknownCommandException.java // public class UnknownCommandException extends RuntimeException { // public UnknownCommandException(String command) { // super("Unknown command: " + command); // } // // private static final long serialVersionUID = 1L; // }
import java.util.function.Function; import com.iamcontent.device.servo.Servo; import com.iamcontent.io.cli.UnknownCommandException;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo.command; /** * An abstract function to parse a String command into a {@link ServoCommand}. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public abstract class ParseStringIntoServoCommand<C> implements Function<String, ServoCommand<C>> { @Override public ServoCommand<C> apply(String command) { try { final Args args = new Args(command); return new ImmutableServoCommand<C>(args.channel, args.value, args.speed, args.acceleration); } catch (Exception e) {
// Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/UnknownCommandException.java // public class UnknownCommandException extends RuntimeException { // public UnknownCommandException(String command) { // super("Unknown command: " + command); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/command/ParseStringIntoServoCommand.java import java.util.function.Function; import com.iamcontent.device.servo.Servo; import com.iamcontent.io.cli.UnknownCommandException; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo.command; /** * An abstract function to parse a String command into a {@link ServoCommand}. * @author Greg Elderfield * * @param <C> The type used to identify the channel of a {@link Servo}. */ public abstract class ParseStringIntoServoCommand<C> implements Function<String, ServoCommand<C>> { @Override public ServoCommand<C> apply(String command) { try { final Args args = new Args(command); return new ImmutableServoCommand<C>(args.channel, args.value, args.speed, args.acceleration); } catch (Exception e) {
throw new UnknownCommandException(command);
IAmContent/public
public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/CommandLineDriver.java
// Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/LicenseWriter.java // public static LicenseWriter licenseWriter() { // return new LicenseWriter(); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/Readers.java // public static BufferedReader bufferedReader(InputStream is) { // return bufferedReader(inputStreamReader(is)); // }
import static com.iamcontent.io.cli.LicenseWriter.licenseWriter; import static com.iamcontent.io.util.Readers.bufferedReader; import java.io.BufferedReader; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; import java.util.stream.Stream;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.cli; /** * Foundation class for Command Line Interface (CLI) drivers. * @author Greg Elderfield */ public abstract class CommandLineDriver { private final LicenseWriter licenseWriter = licenseWriter(); protected final BufferedReader in; private final List<Predicate<String>> commandHandlers = new ArrayList<>(); public CommandLineDriver() {
// Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/LicenseWriter.java // public static LicenseWriter licenseWriter() { // return new LicenseWriter(); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/Readers.java // public static BufferedReader bufferedReader(InputStream is) { // return bufferedReader(inputStreamReader(is)); // } // Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/CommandLineDriver.java import static com.iamcontent.io.cli.LicenseWriter.licenseWriter; import static com.iamcontent.io.util.Readers.bufferedReader; import java.io.BufferedReader; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; import java.util.stream.Stream; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.cli; /** * Foundation class for Command Line Interface (CLI) drivers. * @author Greg Elderfield */ public abstract class CommandLineDriver { private final LicenseWriter licenseWriter = licenseWriter(); protected final BufferedReader in; private final List<Predicate<String>> commandHandlers = new ArrayList<>(); public CommandLineDriver() {
this(bufferedReader(System.in));
IAmContent/public
public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/DoubleRangeTest.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static DoubleRange range(double limit1, double limit2) { // return new DoubleRange(limit1, limit2); // } // // Path: public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/MathUtilsTest.java // public static void assertExactlyEquals(double expected, double actual) { // assertEquals(expected, actual, 0.0); // }
import static org.junit.Assert.assertEquals; import static com.iamcontent.core.math.DoubleRange.range; import static com.iamcontent.core.math.MathUtilsTest.assertExactlyEquals; import org.junit.Test;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.core.math; public class DoubleRangeTest { private static final DoubleRange RANGE_1_TO_10 = range(1.0, 10.0); private static final DoubleRange RANGE_7_TO_3 = range(7.0, 3.0); @Test public void testGetters() { checkGetters(RANGE_1_TO_10, 1.0, 10.0, 1.0, 10.0); checkGetters(RANGE_7_TO_3, 7.0, 3.0, 3.0, 7.0); } private void checkGetters(DoubleRange range, double limit1, double limit2, double min, double max) {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static DoubleRange range(double limit1, double limit2) { // return new DoubleRange(limit1, limit2); // } // // Path: public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/MathUtilsTest.java // public static void assertExactlyEquals(double expected, double actual) { // assertEquals(expected, actual, 0.0); // } // Path: public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/DoubleRangeTest.java import static org.junit.Assert.assertEquals; import static com.iamcontent.core.math.DoubleRange.range; import static com.iamcontent.core.math.MathUtilsTest.assertExactlyEquals; import org.junit.Test; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.core.math; public class DoubleRangeTest { private static final DoubleRange RANGE_1_TO_10 = range(1.0, 10.0); private static final DoubleRange RANGE_7_TO_3 = range(7.0, 3.0); @Test public void testGetters() { checkGetters(RANGE_1_TO_10, 1.0, 10.0, 1.0, 10.0); checkGetters(RANGE_7_TO_3, 7.0, 3.0, 3.0, 7.0); } private void checkGetters(DoubleRange range, double limit1, double limit2, double min, double max) {
assertExactlyEquals(limit1, range.getLimit1());
IAmContent/public
public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/LicenseWriter.java
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/ResourceUtils.java // public static void appendResource(String fileName, Appendable onto) { // resourceAsLineStream(fileName).forEach(l -> appendQuietly(onto, l)); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import com.iamcontent.io.IORuntimeException; import static com.iamcontent.io.util.ResourceUtils.appendResource; import java.io.IOException; import java.util.logging.Logger;
this.productName = productName; this.years = years; this.copyrightHolders = copyrightHolders; } public static LicenseWriter licenseWriter() { return new LicenseWriter(); } public void printInteractiveInstructions() { printWithHeader(INSTRUCTIONS); } public void printNonInteractiveInstructions() { printHeader(); printNonInteractiveTerms(); printFooter(); } public void printTermsAndConditions() { printWithHeader(TERMS_AND_CONDITIONS); } public void printWarranty() { printWithHeader(WARRANTY); } protected void printWithHeader(String file) { printHeader(); try {
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/ResourceUtils.java // public static void appendResource(String fileName, Appendable onto) { // resourceAsLineStream(fileName).forEach(l -> appendQuietly(onto, l)); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/LicenseWriter.java import com.iamcontent.io.IORuntimeException; import static com.iamcontent.io.util.ResourceUtils.appendResource; import java.io.IOException; import java.util.logging.Logger; this.productName = productName; this.years = years; this.copyrightHolders = copyrightHolders; } public static LicenseWriter licenseWriter() { return new LicenseWriter(); } public void printInteractiveInstructions() { printWithHeader(INSTRUCTIONS); } public void printNonInteractiveInstructions() { printHeader(); printNonInteractiveTerms(); printFooter(); } public void printTermsAndConditions() { printWithHeader(TERMS_AND_CONDITIONS); } public void printWarranty() { printWithHeader(WARRANTY); } protected void printWithHeader(String file) { printHeader(); try {
appendResource(file, out);
IAmContent/public
public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/LicenseWriter.java
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/ResourceUtils.java // public static void appendResource(String fileName, Appendable onto) { // resourceAsLineStream(fileName).forEach(l -> appendQuietly(onto, l)); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // }
import com.iamcontent.io.IORuntimeException; import static com.iamcontent.io.util.ResourceUtils.appendResource; import java.io.IOException; import java.util.logging.Logger;
this.years = years; this.copyrightHolders = copyrightHolders; } public static LicenseWriter licenseWriter() { return new LicenseWriter(); } public void printInteractiveInstructions() { printWithHeader(INSTRUCTIONS); } public void printNonInteractiveInstructions() { printHeader(); printNonInteractiveTerms(); printFooter(); } public void printTermsAndConditions() { printWithHeader(TERMS_AND_CONDITIONS); } public void printWarranty() { printWithHeader(WARRANTY); } protected void printWithHeader(String file) { printHeader(); try { appendResource(file, out);
// Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/util/ResourceUtils.java // public static void appendResource(String fileName, Appendable onto) { // resourceAsLineStream(fileName).forEach(l -> appendQuietly(onto, l)); // } // // Path: public-java/io/iamcontent-io-core/src/main/java/com/iamcontent/io/IORuntimeException.java // public class IORuntimeException extends RuntimeException { // // public IORuntimeException(String message) { // super(message); // } // // public IORuntimeException(Throwable cause) { // super(cause); // } // // private static final long serialVersionUID = 1L; // } // Path: public-java/io/iamcontent-cli/src/main/java/com/iamcontent/io/cli/LicenseWriter.java import com.iamcontent.io.IORuntimeException; import static com.iamcontent.io.util.ResourceUtils.appendResource; import java.io.IOException; import java.util.logging.Logger; this.years = years; this.copyrightHolders = copyrightHolders; } public static LicenseWriter licenseWriter() { return new LicenseWriter(); } public void printInteractiveInstructions() { printWithHeader(INSTRUCTIONS); } public void printNonInteractiveInstructions() { printHeader(); printNonInteractiveTerms(); printFooter(); } public void printTermsAndConditions() { printWithHeader(TERMS_AND_CONDITIONS); } public void printWarranty() { printWithHeader(WARRANTY); } protected void printWithHeader(String file) { printHeader(); try { appendResource(file, out);
} catch (IORuntimeException e) {
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/ImmutableServoCalibration.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public static final InterRangeDoubleConverter REVERSE_NORMAL_CONVERTER = converterFromNormalTo(REVERSE_NORMAL_RANGE); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleConverter.java // public interface DoubleConverter { // double applyForward(double v); // double applyBackward(double v); // // static DoubleConverter IDENTITY = new DoubleConverter() { // @Override // public double applyForward(double v) { // return v; // } // // @Override // public double applyBackward(double v) { // return v; // } // }; // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public class InterRangeDoubleConverter implements DoubleConverter { // // public static final ClampingMode DEFAULT_MODE = ClampingMode.CLAMPED; // public static final InterRangeDoubleConverter REVERSE_NORMAL_CONVERTER = converterFromNormalTo(REVERSE_NORMAL_RANGE); // // /** // * Indicates whether a converted value should be clamped to its target range or not. // */ // public static enum ClampingMode { // CLAMPED { // @Override // double apply(double d, DoubleRange r) { // return r.clamp(d); // } // }, // UNCLAMPED { // @Override // double apply(double d, DoubleRange r) { // return d; // } // }; // abstract double apply(double d, DoubleRange r); // }; // // private final DoubleRange fromRange, toRange; // private final ClampingMode clampingMode; // // public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange) { // this(fromRange, toRange, DEFAULT_MODE); // } // // public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange, ClampingMode clampingMode) { // this.fromRange = fromRange; // this.toRange = toRange; // this.clampingMode = clampingMode; // } // // public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { // return converterFromNormalTo(range(toLimit1, toLimit2)); // } // // public static InterRangeDoubleConverter converterFromNormalTo(DoubleRange toRange) { // return interRangeConverter(NORMAL_RANGE, toRange, DEFAULT_MODE); // } // // public static InterRangeDoubleConverter converterFromNormalTo(DoubleRange toRange, ClampingMode clampingMode) { // return interRangeConverter(NORMAL_RANGE, toRange, clampingMode); // } // // public static InterRangeDoubleConverter interRangeConverter(DoubleRange fromRange, DoubleRange toRange) { // return interRangeConverter(fromRange, toRange, DEFAULT_MODE); // } // // public static InterRangeDoubleConverter interRangeConverter(DoubleRange fromRange, DoubleRange toRange, ClampingMode clampingMode) { // return new InterRangeDoubleConverter(fromRange, toRange, clampingMode); // } // // @Override // public double applyForward(double v) { // return convertAndClamp(v, fromRange, toRange); // } // // @Override // public double applyBackward(double v) { // return convertAndClamp(v, toRange, fromRange); // } // // private double convertAndClamp(double d, DoubleRange fromRange, DoubleRange toRange) { // final double convertedButUnclamped = linearConvert(d, fromRange, toRange); // return clampingMode.apply(convertedButUnclamped, toRange); // } // // private static double linearConvert(double v, DoubleRange inRange, DoubleRange outRange) { // return MathUtils.linearConvert(v, inRange.getLimit1(), inRange.getLimit2(), outRange.getLimit1(), outRange.getLimit2()); // } // // public DoubleRange getFromRange() { // return fromRange; // } // // public DoubleRange getToRange() { // return toRange; // } // // public ClampingMode getClampingMode() { // return clampingMode; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoCalibration.java // public interface ServoCalibration extends AnalogIOCalibration, ServoFeatures<DoubleConverter> { // static ServoCalibration IDENTITY = new ImmutableServoCalibration(DoubleConverter.IDENTITY); // }
import static com.iamcontent.core.math.InterRangeDoubleConverter.REVERSE_NORMAL_CONVERTER; import com.iamcontent.core.math.DoubleConverter; import com.iamcontent.core.math.InterRangeDoubleConverter; import com.iamcontent.device.servo.ServoCalibration;
package com.iamcontent.device.servo.impl; /** * Defines an immutable {@link ServoCalibration}. * @author Greg Elderfield */ public class ImmutableServoCalibration implements ServoCalibration { private final DoubleConverter value, speed, acceleration;
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public static final InterRangeDoubleConverter REVERSE_NORMAL_CONVERTER = converterFromNormalTo(REVERSE_NORMAL_RANGE); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleConverter.java // public interface DoubleConverter { // double applyForward(double v); // double applyBackward(double v); // // static DoubleConverter IDENTITY = new DoubleConverter() { // @Override // public double applyForward(double v) { // return v; // } // // @Override // public double applyBackward(double v) { // return v; // } // }; // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public class InterRangeDoubleConverter implements DoubleConverter { // // public static final ClampingMode DEFAULT_MODE = ClampingMode.CLAMPED; // public static final InterRangeDoubleConverter REVERSE_NORMAL_CONVERTER = converterFromNormalTo(REVERSE_NORMAL_RANGE); // // /** // * Indicates whether a converted value should be clamped to its target range or not. // */ // public static enum ClampingMode { // CLAMPED { // @Override // double apply(double d, DoubleRange r) { // return r.clamp(d); // } // }, // UNCLAMPED { // @Override // double apply(double d, DoubleRange r) { // return d; // } // }; // abstract double apply(double d, DoubleRange r); // }; // // private final DoubleRange fromRange, toRange; // private final ClampingMode clampingMode; // // public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange) { // this(fromRange, toRange, DEFAULT_MODE); // } // // public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange, ClampingMode clampingMode) { // this.fromRange = fromRange; // this.toRange = toRange; // this.clampingMode = clampingMode; // } // // public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { // return converterFromNormalTo(range(toLimit1, toLimit2)); // } // // public static InterRangeDoubleConverter converterFromNormalTo(DoubleRange toRange) { // return interRangeConverter(NORMAL_RANGE, toRange, DEFAULT_MODE); // } // // public static InterRangeDoubleConverter converterFromNormalTo(DoubleRange toRange, ClampingMode clampingMode) { // return interRangeConverter(NORMAL_RANGE, toRange, clampingMode); // } // // public static InterRangeDoubleConverter interRangeConverter(DoubleRange fromRange, DoubleRange toRange) { // return interRangeConverter(fromRange, toRange, DEFAULT_MODE); // } // // public static InterRangeDoubleConverter interRangeConverter(DoubleRange fromRange, DoubleRange toRange, ClampingMode clampingMode) { // return new InterRangeDoubleConverter(fromRange, toRange, clampingMode); // } // // @Override // public double applyForward(double v) { // return convertAndClamp(v, fromRange, toRange); // } // // @Override // public double applyBackward(double v) { // return convertAndClamp(v, toRange, fromRange); // } // // private double convertAndClamp(double d, DoubleRange fromRange, DoubleRange toRange) { // final double convertedButUnclamped = linearConvert(d, fromRange, toRange); // return clampingMode.apply(convertedButUnclamped, toRange); // } // // private static double linearConvert(double v, DoubleRange inRange, DoubleRange outRange) { // return MathUtils.linearConvert(v, inRange.getLimit1(), inRange.getLimit2(), outRange.getLimit1(), outRange.getLimit2()); // } // // public DoubleRange getFromRange() { // return fromRange; // } // // public DoubleRange getToRange() { // return toRange; // } // // public ClampingMode getClampingMode() { // return clampingMode; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoCalibration.java // public interface ServoCalibration extends AnalogIOCalibration, ServoFeatures<DoubleConverter> { // static ServoCalibration IDENTITY = new ImmutableServoCalibration(DoubleConverter.IDENTITY); // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/ImmutableServoCalibration.java import static com.iamcontent.core.math.InterRangeDoubleConverter.REVERSE_NORMAL_CONVERTER; import com.iamcontent.core.math.DoubleConverter; import com.iamcontent.core.math.InterRangeDoubleConverter; import com.iamcontent.device.servo.ServoCalibration; package com.iamcontent.device.servo.impl; /** * Defines an immutable {@link ServoCalibration}. * @author Greg Elderfield */ public class ImmutableServoCalibration implements ServoCalibration { private final DoubleConverter value, speed, acceleration;
public static final ServoCalibration REVERSE_NORMAL_SERVO_CALIBRATION = new ImmutableServoCalibration(REVERSE_NORMAL_CONVERTER);
krHasan/Money-Manager
src/controller/NewUserRegistrationController.java
// Path: src/model/NewUserRegistrationModel.java // public class NewUserRegistrationModel extends DateAndClock { // // public ObservableList<String> getSecurityQuestion() { // ObservableList<String> list = FXCollections.observableArrayList(new ComboboxList().getSecurityQuestionList()); // return list; // } // // // } // // Path: src/operation/GoToOperation.java // public class GoToOperation extends UnitConverter { // // public void goToSignIn(Stage SignInStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/SignIn.fxml")); // Scene scene = new Scene(root, 800, 550); // SignInStage.setScene(scene); // SignInStage.setTitle("Money Manager"); // SignInStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToDashboard(Stage DashboardStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/Dashboard.fxml")); // Scene scene = new Scene(root, 800, 550); // DashboardStage.setScene(scene); // DashboardStage.setTitle("Dashboard"); // DashboardStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToMakeATransaction(Stage MakeATransactionStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/MakeATransaction.fxml")); // Scene scene = new Scene(root, 800, 550); // MakeATransactionStage.setScene(scene); // MakeATransactionStage.setTitle("Make A Transaction"); // MakeATransactionStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToSettings(Stage SettingsStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/Settings.fxml")); // Scene scene = new Scene(root, 800, 550); // SettingsStage.setScene(scene); // SettingsStage.setTitle("Settings"); // SettingsStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToTransactionHistory(Stage TransactionHistoryStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/TransactionHistory.fxml")); // Scene scene = new Scene(root, 800, 550); // TransactionHistoryStage.setScene(scene); // TransactionHistoryStage.setTitle("Transaction History"); // TransactionHistoryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToCashCalculate(Stage CashCalculateStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/CashCalculate.fxml")); // Scene scene = new Scene(root, 800, 550); // CashCalculateStage.setScene(scene); // CashCalculateStage.setTitle("Cash Calculate"); // CashCalculateStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToAbout(Stage AboutStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/About.fxml")); // Scene scene = new Scene(root, 800, 550); // AboutStage.setScene(scene); // AboutStage.setTitle("About"); // AboutStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToHelp(Stage HelpStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/Help.fxml")); // Scene scene = new Scene(root, 800, 550); // HelpStage.setScene(scene); // HelpStage.setTitle("Help"); // HelpStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // }
import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.scene.control.Alert; import javafx.scene.control.Button; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; import javafx.scene.control.Tooltip; import javafx.scene.control.Alert.AlertType; import javafx.stage.Stage; import javafx.util.Duration; import model.NewUserRegistrationModel; import operation.GoToOperation;
private Label lblMsg1; ///////////////////////// General Function ////////////// @FXML public void initialize() { loadSQuestion(); btnCancel.setTooltip(new Tooltip("Cancel the registration process and take you to Sign In Window")); btnRegistration.setTooltip(new Tooltip("If all data typed correctly, \n" + "then you will register as a new user")); Tooltip.install(txtName, new Tooltip("Write your full name")); Tooltip.install(txtUsername, new Tooltip("Give a username, this will use at the time of login\n" + "This should not contain space")); Tooltip.install(passPassword, new Tooltip("Give a password, this should not contain space")); Tooltip.install(passReTypePassword, new Tooltip("Retype the password")); Tooltip.install(cmboSecurityQuestion, new Tooltip("Choose a security question")); Tooltip.install(txtAnswer, new Tooltip("Answer your question. Remember this answer.\n" + "If you forget your password, this will \n" + "help you to recover your account.")); } //////////////////////// Function /////////////////////// private void loadSQuestion() { cmboSecurityQuestion.setItems(getSecurityQuestion()); cmboSecurityQuestion.getSelectionModel().selectFirst(); } @FXML private void btnCancel(ActionEvent event) { Stage NewUserRegistrationStage = (Stage) btnCancel.getScene().getWindow();
// Path: src/model/NewUserRegistrationModel.java // public class NewUserRegistrationModel extends DateAndClock { // // public ObservableList<String> getSecurityQuestion() { // ObservableList<String> list = FXCollections.observableArrayList(new ComboboxList().getSecurityQuestionList()); // return list; // } // // // } // // Path: src/operation/GoToOperation.java // public class GoToOperation extends UnitConverter { // // public void goToSignIn(Stage SignInStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/SignIn.fxml")); // Scene scene = new Scene(root, 800, 550); // SignInStage.setScene(scene); // SignInStage.setTitle("Money Manager"); // SignInStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToDashboard(Stage DashboardStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/Dashboard.fxml")); // Scene scene = new Scene(root, 800, 550); // DashboardStage.setScene(scene); // DashboardStage.setTitle("Dashboard"); // DashboardStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToMakeATransaction(Stage MakeATransactionStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/MakeATransaction.fxml")); // Scene scene = new Scene(root, 800, 550); // MakeATransactionStage.setScene(scene); // MakeATransactionStage.setTitle("Make A Transaction"); // MakeATransactionStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToSettings(Stage SettingsStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/Settings.fxml")); // Scene scene = new Scene(root, 800, 550); // SettingsStage.setScene(scene); // SettingsStage.setTitle("Settings"); // SettingsStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToTransactionHistory(Stage TransactionHistoryStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/TransactionHistory.fxml")); // Scene scene = new Scene(root, 800, 550); // TransactionHistoryStage.setScene(scene); // TransactionHistoryStage.setTitle("Transaction History"); // TransactionHistoryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToCashCalculate(Stage CashCalculateStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/CashCalculate.fxml")); // Scene scene = new Scene(root, 800, 550); // CashCalculateStage.setScene(scene); // CashCalculateStage.setTitle("Cash Calculate"); // CashCalculateStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToAbout(Stage AboutStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/About.fxml")); // Scene scene = new Scene(root, 800, 550); // AboutStage.setScene(scene); // AboutStage.setTitle("About"); // AboutStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // public void goToHelp(Stage HelpStage) { // try { // Parent root = FXMLLoader.load(getClass().getResource("/view/Help.fxml")); // Scene scene = new Scene(root, 800, 550); // HelpStage.setScene(scene); // HelpStage.setTitle("Help"); // HelpStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // } // Path: src/controller/NewUserRegistrationController.java import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.scene.control.Alert; import javafx.scene.control.Button; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; import javafx.scene.control.Tooltip; import javafx.scene.control.Alert.AlertType; import javafx.stage.Stage; import javafx.util.Duration; import model.NewUserRegistrationModel; import operation.GoToOperation; private Label lblMsg1; ///////////////////////// General Function ////////////// @FXML public void initialize() { loadSQuestion(); btnCancel.setTooltip(new Tooltip("Cancel the registration process and take you to Sign In Window")); btnRegistration.setTooltip(new Tooltip("If all data typed correctly, \n" + "then you will register as a new user")); Tooltip.install(txtName, new Tooltip("Write your full name")); Tooltip.install(txtUsername, new Tooltip("Give a username, this will use at the time of login\n" + "This should not contain space")); Tooltip.install(passPassword, new Tooltip("Give a password, this should not contain space")); Tooltip.install(passReTypePassword, new Tooltip("Retype the password")); Tooltip.install(cmboSecurityQuestion, new Tooltip("Choose a security question")); Tooltip.install(txtAnswer, new Tooltip("Answer your question. Remember this answer.\n" + "If you forget your password, this will \n" + "help you to recover your account.")); } //////////////////////// Function /////////////////////// private void loadSQuestion() { cmboSecurityQuestion.setItems(getSecurityQuestion()); cmboSecurityQuestion.getSelectionModel().selectFirst(); } @FXML private void btnCancel(ActionEvent event) { Stage NewUserRegistrationStage = (Stage) btnCancel.getScene().getWindow();
(new GoToOperation()).goToSignIn(NewUserRegistrationStage);
krHasan/Money-Manager
src/operation/BalanceStatus.java
// Path: src/system/UnitConverter.java // public class UnitConverter extends DatabaseConnection { // // public static double longToDouble(long balance) { // return balance/100.00; // } // // public static int longToint(long balance) { // return (int) (balance/100); // } // // public static long doubleTolong(double balance) { // return (long) (balance*100); // } // // // public static String doubleToString(double balance) { // return Double.toString(balance); // } // // // public static Double stringToDouble(String balance) { // return Double.parseDouble(balance); // } // // // public static long stringToLong(String balance) { // return (long) (Double.parseDouble(balance)*100); // } // // // public static int stringToInt(String balance) { // return Integer.parseInt(balance); // } // // // public static String intToString(int balance) { // return Integer.toString(balance); // } // // // public static String longToString(long balance) { // return Double.toString(balance/100.00); // } // // // public static String addThousandSeparator(String amount) { // DecimalFormat format = new DecimalFormat("###,###.##"); // try { // return format.format(stringToDouble(amount)); // } catch (Exception e) { // return amount; // } // } // // // public static String removeThousandSeparator(String amount) { // return amount.replace(",", ""); // } // // // public static String getAbbreviateName(String name) { // String abbreviateName = null; // // if (countWords(name) == 1) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // if (getUppercaseLetters(name).equals("none")) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // abbreviateName = getUppercaseLetters(name); // } // } // return abbreviateName; // } // // private static String getUppercaseLetters(String name) { // char uppercaseLetters[] = new char[3]; // int index = 0; // for (int ch = 0; ch < name.length() && index <= 2; ch++) { // // Check for uppercase letters. // if (Character.isUpperCase(name.charAt(ch))) { // uppercaseLetters[index] = name.charAt(ch); // index++; // } // } // if (index == 0) { // return "none"; // } else { // return String.valueOf(uppercaseLetters); // } // } // // public static int countWords(String s){ // int wordCount = 0; // // boolean word = false; // int endOfLine = s.length() - 1; // // for (int i = 0; i < s.length(); i++) { // // if the char is a letter, word = true. // if (Character.isLetterOrDigit(s.charAt(i)) && i != endOfLine) { // word = true; // // if char isn't a letter and there have been letters before, // // counter goes up. // } else if (!Character.isLetter(s.charAt(i)) && word) { // wordCount++; // word = false; // // last word of String; if it doesn't end with a non letter, it // // wouldn't count without this. // } else if (Character.isLetter(s.charAt(i)) && i == endOfLine) { // wordCount++; // } // } // return wordCount; // } // // // public static boolean containswhitespace(String s) { // Pattern pattern = Pattern.compile("\\s"); // Matcher matcher = pattern.matcher(s); // boolean found = matcher.find(); // return found; // } // // // // public static void main(String[] args) { // // UnitConverter access = new UnitConverter(); // // System.out.println(longToDouble(1909)); // // System.out.println(doubleTolong(12.89)); // // System.out.println(addThousandSeparator("9999999")); // // System.out.println(removeThousandSeparator(addThousandSeparator("9999999"))); // // System.out.println(addTSwithTKSign("9999999.99")); // // System.out.println(addTSwithTKSign(addThousandSeparator("9999999"))); // // System.out.println(addTSwithDollerSign("9999999.99")); // // System.out.println(addTSwithDollerSign(addThousandSeparator("9999999"))); // // System.out.println(countWords("11someth ing")); // // System.out.println(access.getUppercaseLetters("khandoker rakib hasan bappi")); // // System.out.println(containswhitespace("ami nai")); // // } // // }
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import system.UnitConverter;
package operation; public class BalanceStatus extends GoToOperation { public static long currentWalletBalance() { long balance = 0; String sql = "SELECT walletBalance \n" + "FROM Current_Status"; try (Connection conn = connector(); Statement stmt = conn.createStatement(); ResultSet result = stmt.executeQuery(sql)) { balance = result.getLong("walletBalance"); } catch (Exception e) { e.printStackTrace(); } return balance; } public void setCurrentWalletBalance(String balance) {
// Path: src/system/UnitConverter.java // public class UnitConverter extends DatabaseConnection { // // public static double longToDouble(long balance) { // return balance/100.00; // } // // public static int longToint(long balance) { // return (int) (balance/100); // } // // public static long doubleTolong(double balance) { // return (long) (balance*100); // } // // // public static String doubleToString(double balance) { // return Double.toString(balance); // } // // // public static Double stringToDouble(String balance) { // return Double.parseDouble(balance); // } // // // public static long stringToLong(String balance) { // return (long) (Double.parseDouble(balance)*100); // } // // // public static int stringToInt(String balance) { // return Integer.parseInt(balance); // } // // // public static String intToString(int balance) { // return Integer.toString(balance); // } // // // public static String longToString(long balance) { // return Double.toString(balance/100.00); // } // // // public static String addThousandSeparator(String amount) { // DecimalFormat format = new DecimalFormat("###,###.##"); // try { // return format.format(stringToDouble(amount)); // } catch (Exception e) { // return amount; // } // } // // // public static String removeThousandSeparator(String amount) { // return amount.replace(",", ""); // } // // // public static String getAbbreviateName(String name) { // String abbreviateName = null; // // if (countWords(name) == 1) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // if (getUppercaseLetters(name).equals("none")) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // abbreviateName = getUppercaseLetters(name); // } // } // return abbreviateName; // } // // private static String getUppercaseLetters(String name) { // char uppercaseLetters[] = new char[3]; // int index = 0; // for (int ch = 0; ch < name.length() && index <= 2; ch++) { // // Check for uppercase letters. // if (Character.isUpperCase(name.charAt(ch))) { // uppercaseLetters[index] = name.charAt(ch); // index++; // } // } // if (index == 0) { // return "none"; // } else { // return String.valueOf(uppercaseLetters); // } // } // // public static int countWords(String s){ // int wordCount = 0; // // boolean word = false; // int endOfLine = s.length() - 1; // // for (int i = 0; i < s.length(); i++) { // // if the char is a letter, word = true. // if (Character.isLetterOrDigit(s.charAt(i)) && i != endOfLine) { // word = true; // // if char isn't a letter and there have been letters before, // // counter goes up. // } else if (!Character.isLetter(s.charAt(i)) && word) { // wordCount++; // word = false; // // last word of String; if it doesn't end with a non letter, it // // wouldn't count without this. // } else if (Character.isLetter(s.charAt(i)) && i == endOfLine) { // wordCount++; // } // } // return wordCount; // } // // // public static boolean containswhitespace(String s) { // Pattern pattern = Pattern.compile("\\s"); // Matcher matcher = pattern.matcher(s); // boolean found = matcher.find(); // return found; // } // // // // public static void main(String[] args) { // // UnitConverter access = new UnitConverter(); // // System.out.println(longToDouble(1909)); // // System.out.println(doubleTolong(12.89)); // // System.out.println(addThousandSeparator("9999999")); // // System.out.println(removeThousandSeparator(addThousandSeparator("9999999"))); // // System.out.println(addTSwithTKSign("9999999.99")); // // System.out.println(addTSwithTKSign(addThousandSeparator("9999999"))); // // System.out.println(addTSwithDollerSign("9999999.99")); // // System.out.println(addTSwithDollerSign(addThousandSeparator("9999999"))); // // System.out.println(countWords("11someth ing")); // // System.out.println(access.getUppercaseLetters("khandoker rakib hasan bappi")); // // System.out.println(containswhitespace("ami nai")); // // } // // } // Path: src/operation/BalanceStatus.java import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import system.UnitConverter; package operation; public class BalanceStatus extends GoToOperation { public static long currentWalletBalance() { long balance = 0; String sql = "SELECT walletBalance \n" + "FROM Current_Status"; try (Connection conn = connector(); Statement stmt = conn.createStatement(); ResultSet result = stmt.executeQuery(sql)) { balance = result.getLong("walletBalance"); } catch (Exception e) { e.printStackTrace(); } return balance; } public void setCurrentWalletBalance(String balance) {
long balancelong = UnitConverter.stringToLong(balance);
krHasan/Money-Manager
src/tableAndgraph/BorrowTableDataModel.java
// Path: src/system/UnitConverter.java // public class UnitConverter extends DatabaseConnection { // // public static double longToDouble(long balance) { // return balance/100.00; // } // // public static int longToint(long balance) { // return (int) (balance/100); // } // // public static long doubleTolong(double balance) { // return (long) (balance*100); // } // // // public static String doubleToString(double balance) { // return Double.toString(balance); // } // // // public static Double stringToDouble(String balance) { // return Double.parseDouble(balance); // } // // // public static long stringToLong(String balance) { // return (long) (Double.parseDouble(balance)*100); // } // // // public static int stringToInt(String balance) { // return Integer.parseInt(balance); // } // // // public static String intToString(int balance) { // return Integer.toString(balance); // } // // // public static String longToString(long balance) { // return Double.toString(balance/100.00); // } // // // public static String addThousandSeparator(String amount) { // DecimalFormat format = new DecimalFormat("###,###.##"); // try { // return format.format(stringToDouble(amount)); // } catch (Exception e) { // return amount; // } // } // // // public static String removeThousandSeparator(String amount) { // return amount.replace(",", ""); // } // // // public static String getAbbreviateName(String name) { // String abbreviateName = null; // // if (countWords(name) == 1) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // if (getUppercaseLetters(name).equals("none")) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // abbreviateName = getUppercaseLetters(name); // } // } // return abbreviateName; // } // // private static String getUppercaseLetters(String name) { // char uppercaseLetters[] = new char[3]; // int index = 0; // for (int ch = 0; ch < name.length() && index <= 2; ch++) { // // Check for uppercase letters. // if (Character.isUpperCase(name.charAt(ch))) { // uppercaseLetters[index] = name.charAt(ch); // index++; // } // } // if (index == 0) { // return "none"; // } else { // return String.valueOf(uppercaseLetters); // } // } // // public static int countWords(String s){ // int wordCount = 0; // // boolean word = false; // int endOfLine = s.length() - 1; // // for (int i = 0; i < s.length(); i++) { // // if the char is a letter, word = true. // if (Character.isLetterOrDigit(s.charAt(i)) && i != endOfLine) { // word = true; // // if char isn't a letter and there have been letters before, // // counter goes up. // } else if (!Character.isLetter(s.charAt(i)) && word) { // wordCount++; // word = false; // // last word of String; if it doesn't end with a non letter, it // // wouldn't count without this. // } else if (Character.isLetter(s.charAt(i)) && i == endOfLine) { // wordCount++; // } // } // return wordCount; // } // // // public static boolean containswhitespace(String s) { // Pattern pattern = Pattern.compile("\\s"); // Matcher matcher = pattern.matcher(s); // boolean found = matcher.find(); // return found; // } // // // // public static void main(String[] args) { // // UnitConverter access = new UnitConverter(); // // System.out.println(longToDouble(1909)); // // System.out.println(doubleTolong(12.89)); // // System.out.println(addThousandSeparator("9999999")); // // System.out.println(removeThousandSeparator(addThousandSeparator("9999999"))); // // System.out.println(addTSwithTKSign("9999999.99")); // // System.out.println(addTSwithTKSign(addThousandSeparator("9999999"))); // // System.out.println(addTSwithDollerSign("9999999.99")); // // System.out.println(addTSwithDollerSign(addThousandSeparator("9999999"))); // // System.out.println(countWords("11someth ing")); // // System.out.println(access.getUppercaseLetters("khandoker rakib hasan bappi")); // // System.out.println(containswhitespace("ami nai")); // // } // // }
import javafx.beans.property.SimpleStringProperty; import system.UnitConverter;
package tableAndgraph; public class BorrowTableDataModel { private SimpleStringProperty boDate; private SimpleStringProperty boWhom; private SimpleStringProperty boExactTk; public BorrowTableDataModel(String Date, String Whom, String ExactTk) { this.boDate = new SimpleStringProperty(Date); this.boWhom = new SimpleStringProperty(Whom);
// Path: src/system/UnitConverter.java // public class UnitConverter extends DatabaseConnection { // // public static double longToDouble(long balance) { // return balance/100.00; // } // // public static int longToint(long balance) { // return (int) (balance/100); // } // // public static long doubleTolong(double balance) { // return (long) (balance*100); // } // // // public static String doubleToString(double balance) { // return Double.toString(balance); // } // // // public static Double stringToDouble(String balance) { // return Double.parseDouble(balance); // } // // // public static long stringToLong(String balance) { // return (long) (Double.parseDouble(balance)*100); // } // // // public static int stringToInt(String balance) { // return Integer.parseInt(balance); // } // // // public static String intToString(int balance) { // return Integer.toString(balance); // } // // // public static String longToString(long balance) { // return Double.toString(balance/100.00); // } // // // public static String addThousandSeparator(String amount) { // DecimalFormat format = new DecimalFormat("###,###.##"); // try { // return format.format(stringToDouble(amount)); // } catch (Exception e) { // return amount; // } // } // // // public static String removeThousandSeparator(String amount) { // return amount.replace(",", ""); // } // // // public static String getAbbreviateName(String name) { // String abbreviateName = null; // // if (countWords(name) == 1) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // if (getUppercaseLetters(name).equals("none")) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // abbreviateName = getUppercaseLetters(name); // } // } // return abbreviateName; // } // // private static String getUppercaseLetters(String name) { // char uppercaseLetters[] = new char[3]; // int index = 0; // for (int ch = 0; ch < name.length() && index <= 2; ch++) { // // Check for uppercase letters. // if (Character.isUpperCase(name.charAt(ch))) { // uppercaseLetters[index] = name.charAt(ch); // index++; // } // } // if (index == 0) { // return "none"; // } else { // return String.valueOf(uppercaseLetters); // } // } // // public static int countWords(String s){ // int wordCount = 0; // // boolean word = false; // int endOfLine = s.length() - 1; // // for (int i = 0; i < s.length(); i++) { // // if the char is a letter, word = true. // if (Character.isLetterOrDigit(s.charAt(i)) && i != endOfLine) { // word = true; // // if char isn't a letter and there have been letters before, // // counter goes up. // } else if (!Character.isLetter(s.charAt(i)) && word) { // wordCount++; // word = false; // // last word of String; if it doesn't end with a non letter, it // // wouldn't count without this. // } else if (Character.isLetter(s.charAt(i)) && i == endOfLine) { // wordCount++; // } // } // return wordCount; // } // // // public static boolean containswhitespace(String s) { // Pattern pattern = Pattern.compile("\\s"); // Matcher matcher = pattern.matcher(s); // boolean found = matcher.find(); // return found; // } // // // // public static void main(String[] args) { // // UnitConverter access = new UnitConverter(); // // System.out.println(longToDouble(1909)); // // System.out.println(doubleTolong(12.89)); // // System.out.println(addThousandSeparator("9999999")); // // System.out.println(removeThousandSeparator(addThousandSeparator("9999999"))); // // System.out.println(addTSwithTKSign("9999999.99")); // // System.out.println(addTSwithTKSign(addThousandSeparator("9999999"))); // // System.out.println(addTSwithDollerSign("9999999.99")); // // System.out.println(addTSwithDollerSign(addThousandSeparator("9999999"))); // // System.out.println(countWords("11someth ing")); // // System.out.println(access.getUppercaseLetters("khandoker rakib hasan bappi")); // // System.out.println(containswhitespace("ami nai")); // // } // // } // Path: src/tableAndgraph/BorrowTableDataModel.java import javafx.beans.property.SimpleStringProperty; import system.UnitConverter; package tableAndgraph; public class BorrowTableDataModel { private SimpleStringProperty boDate; private SimpleStringProperty boWhom; private SimpleStringProperty boExactTk; public BorrowTableDataModel(String Date, String Whom, String ExactTk) { this.boDate = new SimpleStringProperty(Date); this.boWhom = new SimpleStringProperty(Whom);
this.boExactTk = new SimpleStringProperty(UnitConverter.addThousandSeparator(ExactTk));
krHasan/Money-Manager
src/system/DateFormatManager.java
// Path: src/database/DatabaseConnection.java // public class DatabaseConnection { // Connection dbConnection; // // public DatabaseConnection() { // dbConnection = DatabaseConnection.connector(); // } // // public static Connection connector() { // // SQLite connection string // Connection conn = null; // try { // Class.forName("org.sqlite.JDBC"); // //for Linux distribution // String url = "jdbc:sqlite:/home/"+System.getProperty("user.name")+"/Money-ManagerDB/Money_Manager.db"; // // //for Mac distribution // // String url = "jdbc:sqlite:/Users/"+System.getProperty("user.name")+"/Money-ManagerDB/Money_Manager.db"; // // //for Windows distribution // // String url = "jdbc:sqlite:Money_Manager.db"; // // conn = DriverManager.getConnection(url); // // System.out.println("Connection to SQLite has been established."); // } catch (SQLException | ClassNotFoundException e) { // System.out.println(e.getMessage()); // } // return conn; // } // // // public boolean isDBConnected() { // try { // return !dbConnection.isClosed(); // } catch (Exception e) { // e.printStackTrace(); // return false; // } // } // // // public static void main(String[] args) { // // DatabaseConnection access = new DatabaseConnection(); // // System.out.println(access.isDBConnected()); // // } // }
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import database.DatabaseConnection; import javafx.util.StringConverter;
package system; public class DateFormatManager extends StringConverter<LocalDate> { // return the user define date format from database public final String getDateFormat() { String sql = "SELECT dateFormat \n" + "FROM System_Settings"; String format = null;
// Path: src/database/DatabaseConnection.java // public class DatabaseConnection { // Connection dbConnection; // // public DatabaseConnection() { // dbConnection = DatabaseConnection.connector(); // } // // public static Connection connector() { // // SQLite connection string // Connection conn = null; // try { // Class.forName("org.sqlite.JDBC"); // //for Linux distribution // String url = "jdbc:sqlite:/home/"+System.getProperty("user.name")+"/Money-ManagerDB/Money_Manager.db"; // // //for Mac distribution // // String url = "jdbc:sqlite:/Users/"+System.getProperty("user.name")+"/Money-ManagerDB/Money_Manager.db"; // // //for Windows distribution // // String url = "jdbc:sqlite:Money_Manager.db"; // // conn = DriverManager.getConnection(url); // // System.out.println("Connection to SQLite has been established."); // } catch (SQLException | ClassNotFoundException e) { // System.out.println(e.getMessage()); // } // return conn; // } // // // public boolean isDBConnected() { // try { // return !dbConnection.isClosed(); // } catch (Exception e) { // e.printStackTrace(); // return false; // } // } // // // public static void main(String[] args) { // // DatabaseConnection access = new DatabaseConnection(); // // System.out.println(access.isDBConnected()); // // } // } // Path: src/system/DateFormatManager.java import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import database.DatabaseConnection; import javafx.util.StringConverter; package system; public class DateFormatManager extends StringConverter<LocalDate> { // return the user define date format from database public final String getDateFormat() { String sql = "SELECT dateFormat \n" + "FROM System_Settings"; String format = null;
try (Connection conn = DatabaseConnection.connector();
krHasan/Money-Manager
src/tableAndgraph/LendTableDataModel.java
// Path: src/system/UnitConverter.java // public class UnitConverter extends DatabaseConnection { // // public static double longToDouble(long balance) { // return balance/100.00; // } // // public static int longToint(long balance) { // return (int) (balance/100); // } // // public static long doubleTolong(double balance) { // return (long) (balance*100); // } // // // public static String doubleToString(double balance) { // return Double.toString(balance); // } // // // public static Double stringToDouble(String balance) { // return Double.parseDouble(balance); // } // // // public static long stringToLong(String balance) { // return (long) (Double.parseDouble(balance)*100); // } // // // public static int stringToInt(String balance) { // return Integer.parseInt(balance); // } // // // public static String intToString(int balance) { // return Integer.toString(balance); // } // // // public static String longToString(long balance) { // return Double.toString(balance/100.00); // } // // // public static String addThousandSeparator(String amount) { // DecimalFormat format = new DecimalFormat("###,###.##"); // try { // return format.format(stringToDouble(amount)); // } catch (Exception e) { // return amount; // } // } // // // public static String removeThousandSeparator(String amount) { // return amount.replace(",", ""); // } // // // public static String getAbbreviateName(String name) { // String abbreviateName = null; // // if (countWords(name) == 1) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // if (getUppercaseLetters(name).equals("none")) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // abbreviateName = getUppercaseLetters(name); // } // } // return abbreviateName; // } // // private static String getUppercaseLetters(String name) { // char uppercaseLetters[] = new char[3]; // int index = 0; // for (int ch = 0; ch < name.length() && index <= 2; ch++) { // // Check for uppercase letters. // if (Character.isUpperCase(name.charAt(ch))) { // uppercaseLetters[index] = name.charAt(ch); // index++; // } // } // if (index == 0) { // return "none"; // } else { // return String.valueOf(uppercaseLetters); // } // } // // public static int countWords(String s){ // int wordCount = 0; // // boolean word = false; // int endOfLine = s.length() - 1; // // for (int i = 0; i < s.length(); i++) { // // if the char is a letter, word = true. // if (Character.isLetterOrDigit(s.charAt(i)) && i != endOfLine) { // word = true; // // if char isn't a letter and there have been letters before, // // counter goes up. // } else if (!Character.isLetter(s.charAt(i)) && word) { // wordCount++; // word = false; // // last word of String; if it doesn't end with a non letter, it // // wouldn't count without this. // } else if (Character.isLetter(s.charAt(i)) && i == endOfLine) { // wordCount++; // } // } // return wordCount; // } // // // public static boolean containswhitespace(String s) { // Pattern pattern = Pattern.compile("\\s"); // Matcher matcher = pattern.matcher(s); // boolean found = matcher.find(); // return found; // } // // // // public static void main(String[] args) { // // UnitConverter access = new UnitConverter(); // // System.out.println(longToDouble(1909)); // // System.out.println(doubleTolong(12.89)); // // System.out.println(addThousandSeparator("9999999")); // // System.out.println(removeThousandSeparator(addThousandSeparator("9999999"))); // // System.out.println(addTSwithTKSign("9999999.99")); // // System.out.println(addTSwithTKSign(addThousandSeparator("9999999"))); // // System.out.println(addTSwithDollerSign("9999999.99")); // // System.out.println(addTSwithDollerSign(addThousandSeparator("9999999"))); // // System.out.println(countWords("11someth ing")); // // System.out.println(access.getUppercaseLetters("khandoker rakib hasan bappi")); // // System.out.println(containswhitespace("ami nai")); // // } // // }
import javafx.beans.property.SimpleStringProperty; import system.UnitConverter;
package tableAndgraph; public class LendTableDataModel { private SimpleStringProperty leDate; private SimpleStringProperty leWhom; private SimpleStringProperty leExactTk; public LendTableDataModel(String Date, String Whom, String ExactTk) { this.leDate = new SimpleStringProperty(Date); this.leWhom = new SimpleStringProperty(Whom);
// Path: src/system/UnitConverter.java // public class UnitConverter extends DatabaseConnection { // // public static double longToDouble(long balance) { // return balance/100.00; // } // // public static int longToint(long balance) { // return (int) (balance/100); // } // // public static long doubleTolong(double balance) { // return (long) (balance*100); // } // // // public static String doubleToString(double balance) { // return Double.toString(balance); // } // // // public static Double stringToDouble(String balance) { // return Double.parseDouble(balance); // } // // // public static long stringToLong(String balance) { // return (long) (Double.parseDouble(balance)*100); // } // // // public static int stringToInt(String balance) { // return Integer.parseInt(balance); // } // // // public static String intToString(int balance) { // return Integer.toString(balance); // } // // // public static String longToString(long balance) { // return Double.toString(balance/100.00); // } // // // public static String addThousandSeparator(String amount) { // DecimalFormat format = new DecimalFormat("###,###.##"); // try { // return format.format(stringToDouble(amount)); // } catch (Exception e) { // return amount; // } // } // // // public static String removeThousandSeparator(String amount) { // return amount.replace(",", ""); // } // // // public static String getAbbreviateName(String name) { // String abbreviateName = null; // // if (countWords(name) == 1) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // if (getUppercaseLetters(name).equals("none")) { // abbreviateName = name.substring(0, Math.min(name.length(), 3)); // } else { // abbreviateName = getUppercaseLetters(name); // } // } // return abbreviateName; // } // // private static String getUppercaseLetters(String name) { // char uppercaseLetters[] = new char[3]; // int index = 0; // for (int ch = 0; ch < name.length() && index <= 2; ch++) { // // Check for uppercase letters. // if (Character.isUpperCase(name.charAt(ch))) { // uppercaseLetters[index] = name.charAt(ch); // index++; // } // } // if (index == 0) { // return "none"; // } else { // return String.valueOf(uppercaseLetters); // } // } // // public static int countWords(String s){ // int wordCount = 0; // // boolean word = false; // int endOfLine = s.length() - 1; // // for (int i = 0; i < s.length(); i++) { // // if the char is a letter, word = true. // if (Character.isLetterOrDigit(s.charAt(i)) && i != endOfLine) { // word = true; // // if char isn't a letter and there have been letters before, // // counter goes up. // } else if (!Character.isLetter(s.charAt(i)) && word) { // wordCount++; // word = false; // // last word of String; if it doesn't end with a non letter, it // // wouldn't count without this. // } else if (Character.isLetter(s.charAt(i)) && i == endOfLine) { // wordCount++; // } // } // return wordCount; // } // // // public static boolean containswhitespace(String s) { // Pattern pattern = Pattern.compile("\\s"); // Matcher matcher = pattern.matcher(s); // boolean found = matcher.find(); // return found; // } // // // // public static void main(String[] args) { // // UnitConverter access = new UnitConverter(); // // System.out.println(longToDouble(1909)); // // System.out.println(doubleTolong(12.89)); // // System.out.println(addThousandSeparator("9999999")); // // System.out.println(removeThousandSeparator(addThousandSeparator("9999999"))); // // System.out.println(addTSwithTKSign("9999999.99")); // // System.out.println(addTSwithTKSign(addThousandSeparator("9999999"))); // // System.out.println(addTSwithDollerSign("9999999.99")); // // System.out.println(addTSwithDollerSign(addThousandSeparator("9999999"))); // // System.out.println(countWords("11someth ing")); // // System.out.println(access.getUppercaseLetters("khandoker rakib hasan bappi")); // // System.out.println(containswhitespace("ami nai")); // // } // // } // Path: src/tableAndgraph/LendTableDataModel.java import javafx.beans.property.SimpleStringProperty; import system.UnitConverter; package tableAndgraph; public class LendTableDataModel { private SimpleStringProperty leDate; private SimpleStringProperty leWhom; private SimpleStringProperty leExactTk; public LendTableDataModel(String Date, String Whom, String ExactTk) { this.leDate = new SimpleStringProperty(Date); this.leWhom = new SimpleStringProperty(Whom);
this.leExactTk = new SimpleStringProperty(UnitConverter.addThousandSeparator(ExactTk));
Kroger-Technology/Snow-Globe
src/main/java/com/kroger/oss/snowGlobe/NginxEnvironmentFileBuilder.java
// Path: src/main/java/com/kroger/oss/snowGlobe/environment/UpstreamAppInfo.java // public class UpstreamAppInfo { // // private int containerPort; // // /** // * The named port that traffic should be routed to. // * // * @return The port number to use when communicating with the container. // */ // public int port() { // return containerPort; // } // // public void setPort(int port) { // containerPort = port; // } // }
import com.kroger.oss.snowGlobe.environment.UpstreamAppInfo; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; import static java.util.Arrays.stream; import static java.util.stream.Collectors.toList;
/* * Snow-Globe * * Copyright 2017 The Kroger Co. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.kroger.oss.snowGlobe; public class NginxEnvironmentFileBuilder { MessageDigest configurationMD5; FrameworkProperties frameworkProperties;
// Path: src/main/java/com/kroger/oss/snowGlobe/environment/UpstreamAppInfo.java // public class UpstreamAppInfo { // // private int containerPort; // // /** // * The named port that traffic should be routed to. // * // * @return The port number to use when communicating with the container. // */ // public int port() { // return containerPort; // } // // public void setPort(int port) { // containerPort = port; // } // } // Path: src/main/java/com/kroger/oss/snowGlobe/NginxEnvironmentFileBuilder.java import com.kroger.oss.snowGlobe.environment.UpstreamAppInfo; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; import static java.util.Arrays.stream; import static java.util.stream.Collectors.toList; /* * Snow-Globe * * Copyright 2017 The Kroger Co. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.kroger.oss.snowGlobe; public class NginxEnvironmentFileBuilder { MessageDigest configurationMD5; FrameworkProperties frameworkProperties;
Map<String, UpstreamAppInfo> upstreamServers = new HashMap<>();
Kroger-Technology/Snow-Globe
src/test/java/com/kroger/oss/snowGlobe/NginxEnvironmentFileBuilderTest.java
// Path: src/main/java/com/kroger/oss/snowGlobe/environment/UpstreamAppInfo.java // public class UpstreamAppInfo { // // private int containerPort; // // /** // * The named port that traffic should be routed to. // * // * @return The port number to use when communicating with the container. // */ // public int port() { // return containerPort; // } // // public void setPort(int port) { // containerPort = port; // } // }
import com.kroger.oss.snowGlobe.environment.UpstreamAppInfo; import org.junit.Before; import org.junit.Test; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.hamcrest.core.Is.is; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when;
/* * Snow-Globe * * Copyright 2017 The Kroger Co. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.kroger.oss.snowGlobe; public class NginxEnvironmentFileBuilderTest { private NginxEnvironmentFileBuilder fileBuilder; @Before public void setup() { fileBuilder = new NginxEnvironmentFileBuilder(new FrameworkProperties()); } @Test public void shouldBeAbleToAddUpstreamEntry() { final String cluster1 = "cluster1"; final String cluster2 = "cluster2"; fileBuilder.addEmptyCluster("http://" + cluster1); fileBuilder.addEmptyCluster("http://" + cluster2); String clusterFileContents = fileBuilder.buildClusterFileContents();
// Path: src/main/java/com/kroger/oss/snowGlobe/environment/UpstreamAppInfo.java // public class UpstreamAppInfo { // // private int containerPort; // // /** // * The named port that traffic should be routed to. // * // * @return The port number to use when communicating with the container. // */ // public int port() { // return containerPort; // } // // public void setPort(int port) { // containerPort = port; // } // } // Path: src/test/java/com/kroger/oss/snowGlobe/NginxEnvironmentFileBuilderTest.java import com.kroger.oss.snowGlobe.environment.UpstreamAppInfo; import org.junit.Before; import org.junit.Test; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.hamcrest.core.Is.is; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /* * Snow-Globe * * Copyright 2017 The Kroger Co. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.kroger.oss.snowGlobe; public class NginxEnvironmentFileBuilderTest { private NginxEnvironmentFileBuilder fileBuilder; @Before public void setup() { fileBuilder = new NginxEnvironmentFileBuilder(new FrameworkProperties()); } @Test public void shouldBeAbleToAddUpstreamEntry() { final String cluster1 = "cluster1"; final String cluster2 = "cluster2"; fileBuilder.addEmptyCluster("http://" + cluster1); fileBuilder.addEmptyCluster("http://" + cluster2); String clusterFileContents = fileBuilder.buildClusterFileContents();
String expectedContents = fileBuilder.buildUpstreamServerEntry(cluster1, new UpstreamAppInfo()) +
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/FieldRepresentors/JsonObjectRepresentor.java
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/FieldNameParser.java // public class FieldNameParser { // HashSet<NameParserCommand> nameParserCommands; // // public FieldNameParser(HashSet<NameParserCommand> nameParserCommands) { // this.nameParserCommands = nameParserCommands; // } // // public String parseField(String field) { // if (nameParserCommands == null) // return field; // String parsedFieldName = field;//= field; // Iterator<NameParserCommand> fieldParserIterator = nameParserCommands.iterator(); // while (fieldParserIterator.hasNext()) { // NameParserCommand parser = fieldParserIterator.next(); // parsedFieldName = parser.parseFieldName(parsedFieldName); // } // return parsedFieldName; // } // // public String undo(String fieldName) { // if (nameParserCommands == null) // return fieldName; // String unparsed = fieldName;//= field; // Iterator<NameParserCommand> fieldParserIterator = nameParserCommands.iterator(); // while (fieldParserIterator.hasNext()) { // NameParserCommand parser = fieldParserIterator.next(); // unparsed = parser.undoParsing(unparsed); // } // return unparsed; // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // }
import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.FieldNameParser; import com.nvinayshetty.DTOnator.Utility.DtoHelper; import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FieldRepresentors; /** * Created by vinay on 12/7/15. */ public class JsonObjectRepresentor extends FieldRepresentor { FieldNameParser nameParser;
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/FieldNameParser.java // public class FieldNameParser { // HashSet<NameParserCommand> nameParserCommands; // // public FieldNameParser(HashSet<NameParserCommand> nameParserCommands) { // this.nameParserCommands = nameParserCommands; // } // // public String parseField(String field) { // if (nameParserCommands == null) // return field; // String parsedFieldName = field;//= field; // Iterator<NameParserCommand> fieldParserIterator = nameParserCommands.iterator(); // while (fieldParserIterator.hasNext()) { // NameParserCommand parser = fieldParserIterator.next(); // parsedFieldName = parser.parseFieldName(parsedFieldName); // } // return parsedFieldName; // } // // public String undo(String fieldName) { // if (nameParserCommands == null) // return fieldName; // String unparsed = fieldName;//= field; // Iterator<NameParserCommand> fieldParserIterator = nameParserCommands.iterator(); // while (fieldParserIterator.hasNext()) { // NameParserCommand parser = fieldParserIterator.next(); // unparsed = parser.undoParsing(unparsed); // } // return unparsed; // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // } // Path: src/com/nvinayshetty/DTOnator/FieldRepresentors/JsonObjectRepresentor.java import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.FieldNameParser; import com.nvinayshetty.DTOnator.Utility.DtoHelper; import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FieldRepresentors; /** * Created by vinay on 12/7/15. */ public class JsonObjectRepresentor extends FieldRepresentor { FieldNameParser nameParser;
private ClassNameOptions classNameOptions;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/FieldRepresentors/JsonObjectRepresentor.java
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/FieldNameParser.java // public class FieldNameParser { // HashSet<NameParserCommand> nameParserCommands; // // public FieldNameParser(HashSet<NameParserCommand> nameParserCommands) { // this.nameParserCommands = nameParserCommands; // } // // public String parseField(String field) { // if (nameParserCommands == null) // return field; // String parsedFieldName = field;//= field; // Iterator<NameParserCommand> fieldParserIterator = nameParserCommands.iterator(); // while (fieldParserIterator.hasNext()) { // NameParserCommand parser = fieldParserIterator.next(); // parsedFieldName = parser.parseFieldName(parsedFieldName); // } // return parsedFieldName; // } // // public String undo(String fieldName) { // if (nameParserCommands == null) // return fieldName; // String unparsed = fieldName;//= field; // Iterator<NameParserCommand> fieldParserIterator = nameParserCommands.iterator(); // while (fieldParserIterator.hasNext()) { // NameParserCommand parser = fieldParserIterator.next(); // unparsed = parser.undoParsing(unparsed); // } // return unparsed; // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // }
import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.FieldNameParser; import com.nvinayshetty.DTOnator.Utility.DtoHelper; import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FieldRepresentors; /** * Created by vinay on 12/7/15. */ public class JsonObjectRepresentor extends FieldRepresentor { FieldNameParser nameParser; private ClassNameOptions classNameOptions; @Override public String getFieldRepresentationFor(AccessModifier accessModifier, String key) { String fieldName = getSimpleNameForObject(accessModifier, key); return fieldName; } @NotNull private String getSimpleNameForObject(AccessModifier accessModifier, String key) { String Object = key; if (nameParser != null) Object = nameParser.undo(key); String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : "";
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/FieldNameParser.java // public class FieldNameParser { // HashSet<NameParserCommand> nameParserCommands; // // public FieldNameParser(HashSet<NameParserCommand> nameParserCommands) { // this.nameParserCommands = nameParserCommands; // } // // public String parseField(String field) { // if (nameParserCommands == null) // return field; // String parsedFieldName = field;//= field; // Iterator<NameParserCommand> fieldParserIterator = nameParserCommands.iterator(); // while (fieldParserIterator.hasNext()) { // NameParserCommand parser = fieldParserIterator.next(); // parsedFieldName = parser.parseFieldName(parsedFieldName); // } // return parsedFieldName; // } // // public String undo(String fieldName) { // if (nameParserCommands == null) // return fieldName; // String unparsed = fieldName;//= field; // Iterator<NameParserCommand> fieldParserIterator = nameParserCommands.iterator(); // while (fieldParserIterator.hasNext()) { // NameParserCommand parser = fieldParserIterator.next(); // unparsed = parser.undoParsing(unparsed); // } // return unparsed; // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // } // Path: src/com/nvinayshetty/DTOnator/FieldRepresentors/JsonObjectRepresentor.java import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.FieldNameParser; import com.nvinayshetty.DTOnator.Utility.DtoHelper; import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FieldRepresentors; /** * Created by vinay on 12/7/15. */ public class JsonObjectRepresentor extends FieldRepresentor { FieldNameParser nameParser; private ClassNameOptions classNameOptions; @Override public String getFieldRepresentationFor(AccessModifier accessModifier, String key) { String fieldName = getSimpleNameForObject(accessModifier, key); return fieldName; } @NotNull private String getSimpleNameForObject(AccessModifier accessModifier, String key) { String Object = key; if (nameParser != null) Object = nameParser.undo(key); String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : "";
return accessModifier.getModifier() + DtoHelper.firstetterToUpperCase(Object) + clasNameOption + suffix(key);
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassCreatorStrategy.java // public abstract class ClassCreatorStrategy { // // public abstract void addClass(PsiClass psiClass); // // public void organizeCodeStyle(PsiClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingFile()); // styleManager.shortenClassReferences(aClass); // CodeStyleManager codeStyleManager=CodeStyleManager.getInstance(aClass.getProject()); // codeStyleManager.reformat(aClass); // // } // } // // Path: src/com/nvinayshetty/DTOnator/ClassCreator/KotlinClassCreationStrategy.java // public abstract class KotlinClassCreationStrategy { // // // public abstract void addClass(KtClass psiClass, FieldCreationStrategy fieldCreationStrategy); // // public void organizeCodeStyle(KtClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingKtFile()); // styleManager.shortenClassReferences(aClass.getContainingKtFile()); // // } // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // }
import com.nvinayshetty.DTOnator.ClassCreator.ClassCreatorStrategy; import com.nvinayshetty.DTOnator.ClassCreator.KotlinClassCreationStrategy; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import java.util.EnumSet; import java.util.HashSet;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.DtoCreationOptions; /** * Created by vinay on 20/6/15. */ public class DtoCreationOptionsFacade { private FieldCreationStrategy fieldCreationStrategy;
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassCreatorStrategy.java // public abstract class ClassCreatorStrategy { // // public abstract void addClass(PsiClass psiClass); // // public void organizeCodeStyle(PsiClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingFile()); // styleManager.shortenClassReferences(aClass); // CodeStyleManager codeStyleManager=CodeStyleManager.getInstance(aClass.getProject()); // codeStyleManager.reformat(aClass); // // } // } // // Path: src/com/nvinayshetty/DTOnator/ClassCreator/KotlinClassCreationStrategy.java // public abstract class KotlinClassCreationStrategy { // // // public abstract void addClass(KtClass psiClass, FieldCreationStrategy fieldCreationStrategy); // // public void organizeCodeStyle(KtClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingKtFile()); // styleManager.shortenClassReferences(aClass.getContainingKtFile()); // // } // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // } // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java import com.nvinayshetty.DTOnator.ClassCreator.ClassCreatorStrategy; import com.nvinayshetty.DTOnator.ClassCreator.KotlinClassCreationStrategy; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import java.util.EnumSet; import java.util.HashSet; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.DtoCreationOptions; /** * Created by vinay on 20/6/15. */ public class DtoCreationOptionsFacade { private FieldCreationStrategy fieldCreationStrategy;
private ClassCreatorStrategy classAdderStrategy;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassCreatorStrategy.java // public abstract class ClassCreatorStrategy { // // public abstract void addClass(PsiClass psiClass); // // public void organizeCodeStyle(PsiClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingFile()); // styleManager.shortenClassReferences(aClass); // CodeStyleManager codeStyleManager=CodeStyleManager.getInstance(aClass.getProject()); // codeStyleManager.reformat(aClass); // // } // } // // Path: src/com/nvinayshetty/DTOnator/ClassCreator/KotlinClassCreationStrategy.java // public abstract class KotlinClassCreationStrategy { // // // public abstract void addClass(KtClass psiClass, FieldCreationStrategy fieldCreationStrategy); // // public void organizeCodeStyle(KtClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingKtFile()); // styleManager.shortenClassReferences(aClass.getContainingKtFile()); // // } // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // }
import com.nvinayshetty.DTOnator.ClassCreator.ClassCreatorStrategy; import com.nvinayshetty.DTOnator.ClassCreator.KotlinClassCreationStrategy; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import java.util.EnumSet; import java.util.HashSet;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.DtoCreationOptions; /** * Created by vinay on 20/6/15. */ public class DtoCreationOptionsFacade { private FieldCreationStrategy fieldCreationStrategy; private ClassCreatorStrategy classAdderStrategy;
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassCreatorStrategy.java // public abstract class ClassCreatorStrategy { // // public abstract void addClass(PsiClass psiClass); // // public void organizeCodeStyle(PsiClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingFile()); // styleManager.shortenClassReferences(aClass); // CodeStyleManager codeStyleManager=CodeStyleManager.getInstance(aClass.getProject()); // codeStyleManager.reformat(aClass); // // } // } // // Path: src/com/nvinayshetty/DTOnator/ClassCreator/KotlinClassCreationStrategy.java // public abstract class KotlinClassCreationStrategy { // // // public abstract void addClass(KtClass psiClass, FieldCreationStrategy fieldCreationStrategy); // // public void organizeCodeStyle(KtClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingKtFile()); // styleManager.shortenClassReferences(aClass.getContainingKtFile()); // // } // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // } // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java import com.nvinayshetty.DTOnator.ClassCreator.ClassCreatorStrategy; import com.nvinayshetty.DTOnator.ClassCreator.KotlinClassCreationStrategy; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import java.util.EnumSet; import java.util.HashSet; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.DtoCreationOptions; /** * Created by vinay on 20/6/15. */ public class DtoCreationOptionsFacade { private FieldCreationStrategy fieldCreationStrategy; private ClassCreatorStrategy classAdderStrategy;
private KotlinClassCreationStrategy kotlinClassCreationStrategy;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassCreatorStrategy.java // public abstract class ClassCreatorStrategy { // // public abstract void addClass(PsiClass psiClass); // // public void organizeCodeStyle(PsiClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingFile()); // styleManager.shortenClassReferences(aClass); // CodeStyleManager codeStyleManager=CodeStyleManager.getInstance(aClass.getProject()); // codeStyleManager.reformat(aClass); // // } // } // // Path: src/com/nvinayshetty/DTOnator/ClassCreator/KotlinClassCreationStrategy.java // public abstract class KotlinClassCreationStrategy { // // // public abstract void addClass(KtClass psiClass, FieldCreationStrategy fieldCreationStrategy); // // public void organizeCodeStyle(KtClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingKtFile()); // styleManager.shortenClassReferences(aClass.getContainingKtFile()); // // } // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // }
import com.nvinayshetty.DTOnator.ClassCreator.ClassCreatorStrategy; import com.nvinayshetty.DTOnator.ClassCreator.KotlinClassCreationStrategy; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import java.util.EnumSet; import java.util.HashSet;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.DtoCreationOptions; /** * Created by vinay on 20/6/15. */ public class DtoCreationOptionsFacade { private FieldCreationStrategy fieldCreationStrategy; private ClassCreatorStrategy classAdderStrategy; private KotlinClassCreationStrategy kotlinClassCreationStrategy; private AccessModifier accessModifier; private EnumSet<FieldEncapsulationOptions> encapsulationOptionses;
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassCreatorStrategy.java // public abstract class ClassCreatorStrategy { // // public abstract void addClass(PsiClass psiClass); // // public void organizeCodeStyle(PsiClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingFile()); // styleManager.shortenClassReferences(aClass); // CodeStyleManager codeStyleManager=CodeStyleManager.getInstance(aClass.getProject()); // codeStyleManager.reformat(aClass); // // } // } // // Path: src/com/nvinayshetty/DTOnator/ClassCreator/KotlinClassCreationStrategy.java // public abstract class KotlinClassCreationStrategy { // // // public abstract void addClass(KtClass psiClass, FieldCreationStrategy fieldCreationStrategy); // // public void organizeCodeStyle(KtClass aClass) { // JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(aClass.getProject()); // styleManager.optimizeImports(aClass.getContainingKtFile()); // styleManager.shortenClassReferences(aClass.getContainingKtFile()); // // } // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // } // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java import com.nvinayshetty.DTOnator.ClassCreator.ClassCreatorStrategy; import com.nvinayshetty.DTOnator.ClassCreator.KotlinClassCreationStrategy; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import java.util.EnumSet; import java.util.HashSet; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.DtoCreationOptions; /** * Created by vinay on 20/6/15. */ public class DtoCreationOptionsFacade { private FieldCreationStrategy fieldCreationStrategy; private ClassCreatorStrategy classAdderStrategy; private KotlinClassCreationStrategy kotlinClassCreationStrategy; private AccessModifier accessModifier; private EnumSet<FieldEncapsulationOptions> encapsulationOptionses;
public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) {
nvinayshetty/DTOnator
src/test/com/nvinayshetty/DTOnator/fieldRepresentors/JsonArrayRepresentorShould.java
// Path: src/com/nvinayshetty/DTOnator/FieldRepresentors/JsonArrayRepresentor.java // public class JsonArrayRepresentor extends FieldRepresentor { // private String dataType; // private int depth; // private ClassNameOptions classNameOptions; // // protected static String getGsonAnnotationFor(String key) { // return GSON_ANNOTATION_PREFIX + key + ANNOTATION_SUFFIX; // } // // public void setDataType(String dataType) { // this.dataType = dataType; // } // // @Override // public String getFieldRepresentationFor(AccessModifier accessModifier, String key) { // return accessModifier.getModifier() + "java.util.List<" + getSimpleNameForList(dataType) + ">" + suffix(key); // } // // @Override // protected String getKotlinValFieldRepresentationFor(AccessModifier accessModifier, String key) { // String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : ""; // return "val " + key +clasNameOption+ " :List<" + getSimpleNameForList(dataType) + ">"; // } // // @Override // protected String getKotlinVarFieldRepresentationFor(AccessModifier accessModifier, String key) { // String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : ""; // return "var " + key+clasNameOption + " :List<" + getSimpleNameForList(dataType) + ">"; // } // // public void setClassNameOption(ClassNameOptions classNameOptions) { // this.classNameOptions = classNameOptions; // } // // private String getSimpleNameForList(String simpleName) { // // String name = ""; // for (int i = 1; i < depth; i++) { // name += "java.util.List<"; // } // String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : ""; // name += DtoHelper.firstetterToUpperCase(simpleName)+clasNameOption; // for (int i = 1; i < depth; i++) { // name += ">"; // } // return name; // } // // public String getGsonFieldRepresentationFor(AccessModifier AccessModifier, String key) { // return getGsonAnnotationFor(key) + getFieldRepresentationFor(AccessModifier, key); // } // // public void setDepth(int depth) { // this.depth = depth; // } // }
import static junit.framework.TestCase.assertEquals; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldRepresentors.JsonArrayRepresentor; import org.junit.Test;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.fieldRepresentors; /** * Created by vinay on 1/8/15. */ public class JsonArrayRepresentorShould { private String fieldName; private String dataType; @Test public void CreateSimplePublicListWhenAcessModifierIsPublic() { fieldName = "valid"; dataType = "String";
// Path: src/com/nvinayshetty/DTOnator/FieldRepresentors/JsonArrayRepresentor.java // public class JsonArrayRepresentor extends FieldRepresentor { // private String dataType; // private int depth; // private ClassNameOptions classNameOptions; // // protected static String getGsonAnnotationFor(String key) { // return GSON_ANNOTATION_PREFIX + key + ANNOTATION_SUFFIX; // } // // public void setDataType(String dataType) { // this.dataType = dataType; // } // // @Override // public String getFieldRepresentationFor(AccessModifier accessModifier, String key) { // return accessModifier.getModifier() + "java.util.List<" + getSimpleNameForList(dataType) + ">" + suffix(key); // } // // @Override // protected String getKotlinValFieldRepresentationFor(AccessModifier accessModifier, String key) { // String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : ""; // return "val " + key +clasNameOption+ " :List<" + getSimpleNameForList(dataType) + ">"; // } // // @Override // protected String getKotlinVarFieldRepresentationFor(AccessModifier accessModifier, String key) { // String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : ""; // return "var " + key+clasNameOption + " :List<" + getSimpleNameForList(dataType) + ">"; // } // // public void setClassNameOption(ClassNameOptions classNameOptions) { // this.classNameOptions = classNameOptions; // } // // private String getSimpleNameForList(String simpleName) { // // String name = ""; // for (int i = 1; i < depth; i++) { // name += "java.util.List<"; // } // String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : ""; // name += DtoHelper.firstetterToUpperCase(simpleName)+clasNameOption; // for (int i = 1; i < depth; i++) { // name += ">"; // } // return name; // } // // public String getGsonFieldRepresentationFor(AccessModifier AccessModifier, String key) { // return getGsonAnnotationFor(key) + getFieldRepresentationFor(AccessModifier, key); // } // // public void setDepth(int depth) { // this.depth = depth; // } // } // Path: src/test/com/nvinayshetty/DTOnator/fieldRepresentors/JsonArrayRepresentorShould.java import static junit.framework.TestCase.assertEquals; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldRepresentors.JsonArrayRepresentor; import org.junit.Test; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.fieldRepresentors; /** * Created by vinay on 1/8/15. */ public class JsonArrayRepresentorShould { private String fieldName; private String dataType; @Test public void CreateSimplePublicListWhenAcessModifierIsPublic() { fieldName = "valid"; dataType = "String";
JsonArrayRepresentor jsonArrayRepresentor = new JsonArrayRepresentor();
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/persistence/DtonatorPreferences.java
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassType.java // public enum ClassType { // SINGLE_FILE_WITH_INNER_CLASS, SEPARATE_FILE // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldEncapsulationOptions.java // public enum FieldEncapsulationOptions { // PROVIDE_GETTER, PROVIDE_SETTER, PROVIDE_PRIVATE_FIELD // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldType.java // public enum FieldType { // GSON, POJO,GSON_EXPOSE,JACKSON,CUSTOM,AUTO_VALUE // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // }
import java.util.EnumSet; import java.util.List; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.XmlSerializerUtil; import com.nvinayshetty.DTOnator.ClassCreator.ClassType; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldEncapsulationOptions; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldType; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import org.jetbrains.annotations.Nullable;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.persistence; @State( name = "DtonatorPreferences", storages = { @Storage("DtonatorPreferences.xml")} ) public class DtonatorPreferences implements PersistentStateComponent<DtonatorPreferences> {
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassType.java // public enum ClassType { // SINGLE_FILE_WITH_INNER_CLASS, SEPARATE_FILE // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldEncapsulationOptions.java // public enum FieldEncapsulationOptions { // PROVIDE_GETTER, PROVIDE_SETTER, PROVIDE_PRIVATE_FIELD // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldType.java // public enum FieldType { // GSON, POJO,GSON_EXPOSE,JACKSON,CUSTOM,AUTO_VALUE // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // Path: src/com/nvinayshetty/DTOnator/persistence/DtonatorPreferences.java import java.util.EnumSet; import java.util.List; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.XmlSerializerUtil; import com.nvinayshetty.DTOnator.ClassCreator.ClassType; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldEncapsulationOptions; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldType; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import org.jetbrains.annotations.Nullable; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.persistence; @State( name = "DtonatorPreferences", storages = { @Storage("DtonatorPreferences.xml")} ) public class DtonatorPreferences implements PersistentStateComponent<DtonatorPreferences> {
private FieldType fieldType;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/persistence/DtonatorPreferences.java
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassType.java // public enum ClassType { // SINGLE_FILE_WITH_INNER_CLASS, SEPARATE_FILE // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldEncapsulationOptions.java // public enum FieldEncapsulationOptions { // PROVIDE_GETTER, PROVIDE_SETTER, PROVIDE_PRIVATE_FIELD // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldType.java // public enum FieldType { // GSON, POJO,GSON_EXPOSE,JACKSON,CUSTOM,AUTO_VALUE // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // }
import java.util.EnumSet; import java.util.List; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.XmlSerializerUtil; import com.nvinayshetty.DTOnator.ClassCreator.ClassType; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldEncapsulationOptions; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldType; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import org.jetbrains.annotations.Nullable;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.persistence; @State( name = "DtonatorPreferences", storages = { @Storage("DtonatorPreferences.xml")} ) public class DtonatorPreferences implements PersistentStateComponent<DtonatorPreferences> { private FieldType fieldType;
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassType.java // public enum ClassType { // SINGLE_FILE_WITH_INNER_CLASS, SEPARATE_FILE // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldEncapsulationOptions.java // public enum FieldEncapsulationOptions { // PROVIDE_GETTER, PROVIDE_SETTER, PROVIDE_PRIVATE_FIELD // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldType.java // public enum FieldType { // GSON, POJO,GSON_EXPOSE,JACKSON,CUSTOM,AUTO_VALUE // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // Path: src/com/nvinayshetty/DTOnator/persistence/DtonatorPreferences.java import java.util.EnumSet; import java.util.List; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.XmlSerializerUtil; import com.nvinayshetty.DTOnator.ClassCreator.ClassType; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldEncapsulationOptions; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldType; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import org.jetbrains.annotations.Nullable; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.persistence; @State( name = "DtonatorPreferences", storages = { @Storage("DtonatorPreferences.xml")} ) public class DtonatorPreferences implements PersistentStateComponent<DtonatorPreferences> { private FieldType fieldType;
private ClassType classType;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/persistence/DtonatorPreferences.java
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassType.java // public enum ClassType { // SINGLE_FILE_WITH_INNER_CLASS, SEPARATE_FILE // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldEncapsulationOptions.java // public enum FieldEncapsulationOptions { // PROVIDE_GETTER, PROVIDE_SETTER, PROVIDE_PRIVATE_FIELD // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldType.java // public enum FieldType { // GSON, POJO,GSON_EXPOSE,JACKSON,CUSTOM,AUTO_VALUE // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // }
import java.util.EnumSet; import java.util.List; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.XmlSerializerUtil; import com.nvinayshetty.DTOnator.ClassCreator.ClassType; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldEncapsulationOptions; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldType; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import org.jetbrains.annotations.Nullable;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.persistence; @State( name = "DtonatorPreferences", storages = { @Storage("DtonatorPreferences.xml")} ) public class DtonatorPreferences implements PersistentStateComponent<DtonatorPreferences> { private FieldType fieldType; private ClassType classType; private KotlinOptions kotlinOptions;
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassType.java // public enum ClassType { // SINGLE_FILE_WITH_INNER_CLASS, SEPARATE_FILE // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldEncapsulationOptions.java // public enum FieldEncapsulationOptions { // PROVIDE_GETTER, PROVIDE_SETTER, PROVIDE_PRIVATE_FIELD // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldType.java // public enum FieldType { // GSON, POJO,GSON_EXPOSE,JACKSON,CUSTOM,AUTO_VALUE // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // Path: src/com/nvinayshetty/DTOnator/persistence/DtonatorPreferences.java import java.util.EnumSet; import java.util.List; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.XmlSerializerUtil; import com.nvinayshetty.DTOnator.ClassCreator.ClassType; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldEncapsulationOptions; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldType; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import org.jetbrains.annotations.Nullable; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.persistence; @State( name = "DtonatorPreferences", storages = { @Storage("DtonatorPreferences.xml")} ) public class DtonatorPreferences implements PersistentStateComponent<DtonatorPreferences> { private FieldType fieldType; private ClassType classType; private KotlinOptions kotlinOptions;
private List<FieldEncapsulationOptions> encapsulete;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/persistence/DtonatorPreferences.java
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassType.java // public enum ClassType { // SINGLE_FILE_WITH_INNER_CLASS, SEPARATE_FILE // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldEncapsulationOptions.java // public enum FieldEncapsulationOptions { // PROVIDE_GETTER, PROVIDE_SETTER, PROVIDE_PRIVATE_FIELD // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldType.java // public enum FieldType { // GSON, POJO,GSON_EXPOSE,JACKSON,CUSTOM,AUTO_VALUE // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // }
import java.util.EnumSet; import java.util.List; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.XmlSerializerUtil; import com.nvinayshetty.DTOnator.ClassCreator.ClassType; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldEncapsulationOptions; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldType; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import org.jetbrains.annotations.Nullable;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.persistence; @State( name = "DtonatorPreferences", storages = { @Storage("DtonatorPreferences.xml")} ) public class DtonatorPreferences implements PersistentStateComponent<DtonatorPreferences> { private FieldType fieldType; private ClassType classType; private KotlinOptions kotlinOptions; private List<FieldEncapsulationOptions> encapsulete; private List<Naming> naming; private String preixingName="";
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassType.java // public enum ClassType { // SINGLE_FILE_WITH_INNER_CLASS, SEPARATE_FILE // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldEncapsulationOptions.java // public enum FieldEncapsulationOptions { // PROVIDE_GETTER, PROVIDE_SETTER, PROVIDE_PRIVATE_FIELD // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldType.java // public enum FieldType { // GSON, POJO,GSON_EXPOSE,JACKSON,CUSTOM,AUTO_VALUE // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // Path: src/com/nvinayshetty/DTOnator/persistence/DtonatorPreferences.java import java.util.EnumSet; import java.util.List; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.XmlSerializerUtil; import com.nvinayshetty.DTOnator.ClassCreator.ClassType; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldEncapsulationOptions; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldType; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import org.jetbrains.annotations.Nullable; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.persistence; @State( name = "DtonatorPreferences", storages = { @Storage("DtonatorPreferences.xml")} ) public class DtonatorPreferences implements PersistentStateComponent<DtonatorPreferences> { private FieldType fieldType; private ClassType classType; private KotlinOptions kotlinOptions; private List<FieldEncapsulationOptions> encapsulete; private List<Naming> naming; private String preixingName="";
private ClassNameOptions classNameOptions;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/persistence/DtonatorPreferences.java
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassType.java // public enum ClassType { // SINGLE_FILE_WITH_INNER_CLASS, SEPARATE_FILE // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldEncapsulationOptions.java // public enum FieldEncapsulationOptions { // PROVIDE_GETTER, PROVIDE_SETTER, PROVIDE_PRIVATE_FIELD // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldType.java // public enum FieldType { // GSON, POJO,GSON_EXPOSE,JACKSON,CUSTOM,AUTO_VALUE // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // }
import java.util.EnumSet; import java.util.List; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.XmlSerializerUtil; import com.nvinayshetty.DTOnator.ClassCreator.ClassType; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldEncapsulationOptions; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldType; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import org.jetbrains.annotations.Nullable;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.persistence; @State( name = "DtonatorPreferences", storages = { @Storage("DtonatorPreferences.xml")} ) public class DtonatorPreferences implements PersistentStateComponent<DtonatorPreferences> { private FieldType fieldType; private ClassType classType; private KotlinOptions kotlinOptions; private List<FieldEncapsulationOptions> encapsulete; private List<Naming> naming; private String preixingName=""; private ClassNameOptions classNameOptions; private String customAnnotationPattern;
// Path: src/com/nvinayshetty/DTOnator/ClassCreator/ClassType.java // public enum ClassType { // SINGLE_FILE_WITH_INNER_CLASS, SEPARATE_FILE // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldEncapsulationOptions.java // public enum FieldEncapsulationOptions { // PROVIDE_GETTER, PROVIDE_SETTER, PROVIDE_PRIVATE_FIELD // } // // Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/FieldType.java // public enum FieldType { // GSON, POJO,GSON_EXPOSE,JACKSON,CUSTOM,AUTO_VALUE // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // Path: src/com/nvinayshetty/DTOnator/persistence/DtonatorPreferences.java import java.util.EnumSet; import java.util.List; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.project.Project; import com.intellij.util.xmlb.XmlSerializerUtil; import com.nvinayshetty.DTOnator.ClassCreator.ClassType; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldEncapsulationOptions; import com.nvinayshetty.DTOnator.DtoCreationOptions.FieldType; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import org.jetbrains.annotations.Nullable; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.persistence; @State( name = "DtonatorPreferences", storages = { @Storage("DtonatorPreferences.xml")} ) public class DtonatorPreferences implements PersistentStateComponent<DtonatorPreferences> { private FieldType fieldType; private ClassType classType; private KotlinOptions kotlinOptions; private List<FieldEncapsulationOptions> encapsulete; private List<Naming> naming; private String preixingName=""; private ClassNameOptions classNameOptions; private String customAnnotationPattern;
private LanguageType languageType;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/FeedParser/JsonDtoBuilder.java
// Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java // public class DtoCreationOptionsFacade { // private FieldCreationStrategy fieldCreationStrategy; // private ClassCreatorStrategy classAdderStrategy; // private KotlinClassCreationStrategy kotlinClassCreationStrategy; // private AccessModifier accessModifier; // private EnumSet<FieldEncapsulationOptions> encapsulationOptionses; // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.classAdderStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, KotlinClassCreationStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.kotlinClassCreationStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public FieldCreationStrategy getFieldCreationStrategy() { // return fieldCreationStrategy; // } // // // public ClassCreatorStrategy getClassCreationStrategy() { // return classAdderStrategy; // } // // public KotlinClassCreationStrategy getKotlinClassCreationStrategy() { // return kotlinClassCreationStrategy; // } // // public AccessModifier getAccessModifier() { // return accessModifier; // } // // public void setAccessModifier(AccessModifier accessModifier) { // this.accessModifier = accessModifier; // } // // public EnumSet<FieldEncapsulationOptions> getEncapsulationOptionses() { // return encapsulationOptionses; // } // // // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NameParserCommand.java // public interface NameParserCommand { // String parseFieldName(String name); // // String undoParsing(String name); // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // }
import com.intellij.psi.PsiClass; import com.nvinayshetty.DTOnator.DtoCreationOptions.DtoCreationOptionsFacade; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.NameParserCommand; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import org.jetbrains.kotlin.psi.KtClass; import java.util.HashSet;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FeedParser; public class JsonDtoBuilder { String json; PsiClass classUnderCaret; KtClass ktClass;
// Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java // public class DtoCreationOptionsFacade { // private FieldCreationStrategy fieldCreationStrategy; // private ClassCreatorStrategy classAdderStrategy; // private KotlinClassCreationStrategy kotlinClassCreationStrategy; // private AccessModifier accessModifier; // private EnumSet<FieldEncapsulationOptions> encapsulationOptionses; // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.classAdderStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, KotlinClassCreationStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.kotlinClassCreationStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public FieldCreationStrategy getFieldCreationStrategy() { // return fieldCreationStrategy; // } // // // public ClassCreatorStrategy getClassCreationStrategy() { // return classAdderStrategy; // } // // public KotlinClassCreationStrategy getKotlinClassCreationStrategy() { // return kotlinClassCreationStrategy; // } // // public AccessModifier getAccessModifier() { // return accessModifier; // } // // public void setAccessModifier(AccessModifier accessModifier) { // this.accessModifier = accessModifier; // } // // public EnumSet<FieldEncapsulationOptions> getEncapsulationOptionses() { // return encapsulationOptionses; // } // // // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NameParserCommand.java // public interface NameParserCommand { // String parseFieldName(String name); // // String undoParsing(String name); // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // } // Path: src/com/nvinayshetty/DTOnator/FeedParser/JsonDtoBuilder.java import com.intellij.psi.PsiClass; import com.nvinayshetty.DTOnator.DtoCreationOptions.DtoCreationOptionsFacade; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.NameParserCommand; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import org.jetbrains.kotlin.psi.KtClass; import java.util.HashSet; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FeedParser; public class JsonDtoBuilder { String json; PsiClass classUnderCaret; KtClass ktClass;
DtoCreationOptionsFacade dtoCreationOptionsFacade;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/FeedParser/JsonDtoBuilder.java
// Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java // public class DtoCreationOptionsFacade { // private FieldCreationStrategy fieldCreationStrategy; // private ClassCreatorStrategy classAdderStrategy; // private KotlinClassCreationStrategy kotlinClassCreationStrategy; // private AccessModifier accessModifier; // private EnumSet<FieldEncapsulationOptions> encapsulationOptionses; // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.classAdderStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, KotlinClassCreationStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.kotlinClassCreationStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public FieldCreationStrategy getFieldCreationStrategy() { // return fieldCreationStrategy; // } // // // public ClassCreatorStrategy getClassCreationStrategy() { // return classAdderStrategy; // } // // public KotlinClassCreationStrategy getKotlinClassCreationStrategy() { // return kotlinClassCreationStrategy; // } // // public AccessModifier getAccessModifier() { // return accessModifier; // } // // public void setAccessModifier(AccessModifier accessModifier) { // this.accessModifier = accessModifier; // } // // public EnumSet<FieldEncapsulationOptions> getEncapsulationOptionses() { // return encapsulationOptionses; // } // // // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NameParserCommand.java // public interface NameParserCommand { // String parseFieldName(String name); // // String undoParsing(String name); // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // }
import com.intellij.psi.PsiClass; import com.nvinayshetty.DTOnator.DtoCreationOptions.DtoCreationOptionsFacade; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.NameParserCommand; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import org.jetbrains.kotlin.psi.KtClass; import java.util.HashSet;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FeedParser; public class JsonDtoBuilder { String json; PsiClass classUnderCaret; KtClass ktClass; DtoCreationOptionsFacade dtoCreationOptionsFacade;
// Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java // public class DtoCreationOptionsFacade { // private FieldCreationStrategy fieldCreationStrategy; // private ClassCreatorStrategy classAdderStrategy; // private KotlinClassCreationStrategy kotlinClassCreationStrategy; // private AccessModifier accessModifier; // private EnumSet<FieldEncapsulationOptions> encapsulationOptionses; // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.classAdderStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, KotlinClassCreationStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.kotlinClassCreationStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public FieldCreationStrategy getFieldCreationStrategy() { // return fieldCreationStrategy; // } // // // public ClassCreatorStrategy getClassCreationStrategy() { // return classAdderStrategy; // } // // public KotlinClassCreationStrategy getKotlinClassCreationStrategy() { // return kotlinClassCreationStrategy; // } // // public AccessModifier getAccessModifier() { // return accessModifier; // } // // public void setAccessModifier(AccessModifier accessModifier) { // this.accessModifier = accessModifier; // } // // public EnumSet<FieldEncapsulationOptions> getEncapsulationOptionses() { // return encapsulationOptionses; // } // // // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NameParserCommand.java // public interface NameParserCommand { // String parseFieldName(String name); // // String undoParsing(String name); // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // } // Path: src/com/nvinayshetty/DTOnator/FeedParser/JsonDtoBuilder.java import com.intellij.psi.PsiClass; import com.nvinayshetty.DTOnator.DtoCreationOptions.DtoCreationOptionsFacade; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.NameParserCommand; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import org.jetbrains.kotlin.psi.KtClass; import java.util.HashSet; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FeedParser; public class JsonDtoBuilder { String json; PsiClass classUnderCaret; KtClass ktClass; DtoCreationOptionsFacade dtoCreationOptionsFacade;
HashSet<NameConflictResolverCommand> nameConflictResolverCommands;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/FeedParser/JsonDtoBuilder.java
// Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java // public class DtoCreationOptionsFacade { // private FieldCreationStrategy fieldCreationStrategy; // private ClassCreatorStrategy classAdderStrategy; // private KotlinClassCreationStrategy kotlinClassCreationStrategy; // private AccessModifier accessModifier; // private EnumSet<FieldEncapsulationOptions> encapsulationOptionses; // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.classAdderStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, KotlinClassCreationStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.kotlinClassCreationStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public FieldCreationStrategy getFieldCreationStrategy() { // return fieldCreationStrategy; // } // // // public ClassCreatorStrategy getClassCreationStrategy() { // return classAdderStrategy; // } // // public KotlinClassCreationStrategy getKotlinClassCreationStrategy() { // return kotlinClassCreationStrategy; // } // // public AccessModifier getAccessModifier() { // return accessModifier; // } // // public void setAccessModifier(AccessModifier accessModifier) { // this.accessModifier = accessModifier; // } // // public EnumSet<FieldEncapsulationOptions> getEncapsulationOptionses() { // return encapsulationOptionses; // } // // // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NameParserCommand.java // public interface NameParserCommand { // String parseFieldName(String name); // // String undoParsing(String name); // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // }
import com.intellij.psi.PsiClass; import com.nvinayshetty.DTOnator.DtoCreationOptions.DtoCreationOptionsFacade; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.NameParserCommand; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import org.jetbrains.kotlin.psi.KtClass; import java.util.HashSet;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FeedParser; public class JsonDtoBuilder { String json; PsiClass classUnderCaret; KtClass ktClass; DtoCreationOptionsFacade dtoCreationOptionsFacade; HashSet<NameConflictResolverCommand> nameConflictResolverCommands;
// Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java // public class DtoCreationOptionsFacade { // private FieldCreationStrategy fieldCreationStrategy; // private ClassCreatorStrategy classAdderStrategy; // private KotlinClassCreationStrategy kotlinClassCreationStrategy; // private AccessModifier accessModifier; // private EnumSet<FieldEncapsulationOptions> encapsulationOptionses; // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.classAdderStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, KotlinClassCreationStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.kotlinClassCreationStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public FieldCreationStrategy getFieldCreationStrategy() { // return fieldCreationStrategy; // } // // // public ClassCreatorStrategy getClassCreationStrategy() { // return classAdderStrategy; // } // // public KotlinClassCreationStrategy getKotlinClassCreationStrategy() { // return kotlinClassCreationStrategy; // } // // public AccessModifier getAccessModifier() { // return accessModifier; // } // // public void setAccessModifier(AccessModifier accessModifier) { // this.accessModifier = accessModifier; // } // // public EnumSet<FieldEncapsulationOptions> getEncapsulationOptionses() { // return encapsulationOptionses; // } // // // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NameParserCommand.java // public interface NameParserCommand { // String parseFieldName(String name); // // String undoParsing(String name); // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // } // Path: src/com/nvinayshetty/DTOnator/FeedParser/JsonDtoBuilder.java import com.intellij.psi.PsiClass; import com.nvinayshetty.DTOnator.DtoCreationOptions.DtoCreationOptionsFacade; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.NameParserCommand; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import org.jetbrains.kotlin.psi.KtClass; import java.util.HashSet; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FeedParser; public class JsonDtoBuilder { String json; PsiClass classUnderCaret; KtClass ktClass; DtoCreationOptionsFacade dtoCreationOptionsFacade; HashSet<NameConflictResolverCommand> nameConflictResolverCommands;
HashSet<NameParserCommand> feildNameParser;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/FeedParser/JsonDtoBuilder.java
// Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java // public class DtoCreationOptionsFacade { // private FieldCreationStrategy fieldCreationStrategy; // private ClassCreatorStrategy classAdderStrategy; // private KotlinClassCreationStrategy kotlinClassCreationStrategy; // private AccessModifier accessModifier; // private EnumSet<FieldEncapsulationOptions> encapsulationOptionses; // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.classAdderStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, KotlinClassCreationStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.kotlinClassCreationStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public FieldCreationStrategy getFieldCreationStrategy() { // return fieldCreationStrategy; // } // // // public ClassCreatorStrategy getClassCreationStrategy() { // return classAdderStrategy; // } // // public KotlinClassCreationStrategy getKotlinClassCreationStrategy() { // return kotlinClassCreationStrategy; // } // // public AccessModifier getAccessModifier() { // return accessModifier; // } // // public void setAccessModifier(AccessModifier accessModifier) { // this.accessModifier = accessModifier; // } // // public EnumSet<FieldEncapsulationOptions> getEncapsulationOptionses() { // return encapsulationOptionses; // } // // // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NameParserCommand.java // public interface NameParserCommand { // String parseFieldName(String name); // // String undoParsing(String name); // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // }
import com.intellij.psi.PsiClass; import com.nvinayshetty.DTOnator.DtoCreationOptions.DtoCreationOptionsFacade; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.NameParserCommand; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import org.jetbrains.kotlin.psi.KtClass; import java.util.HashSet;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FeedParser; public class JsonDtoBuilder { String json; PsiClass classUnderCaret; KtClass ktClass; DtoCreationOptionsFacade dtoCreationOptionsFacade; HashSet<NameConflictResolverCommand> nameConflictResolverCommands; HashSet<NameParserCommand> feildNameParser;
// Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java // public class DtoCreationOptionsFacade { // private FieldCreationStrategy fieldCreationStrategy; // private ClassCreatorStrategy classAdderStrategy; // private KotlinClassCreationStrategy kotlinClassCreationStrategy; // private AccessModifier accessModifier; // private EnumSet<FieldEncapsulationOptions> encapsulationOptionses; // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.classAdderStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, KotlinClassCreationStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.kotlinClassCreationStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public FieldCreationStrategy getFieldCreationStrategy() { // return fieldCreationStrategy; // } // // // public ClassCreatorStrategy getClassCreationStrategy() { // return classAdderStrategy; // } // // public KotlinClassCreationStrategy getKotlinClassCreationStrategy() { // return kotlinClassCreationStrategy; // } // // public AccessModifier getAccessModifier() { // return accessModifier; // } // // public void setAccessModifier(AccessModifier accessModifier) { // this.accessModifier = accessModifier; // } // // public EnumSet<FieldEncapsulationOptions> getEncapsulationOptionses() { // return encapsulationOptionses; // } // // // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NameParserCommand.java // public interface NameParserCommand { // String parseFieldName(String name); // // String undoParsing(String name); // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // } // Path: src/com/nvinayshetty/DTOnator/FeedParser/JsonDtoBuilder.java import com.intellij.psi.PsiClass; import com.nvinayshetty.DTOnator.DtoCreationOptions.DtoCreationOptionsFacade; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.NameParserCommand; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import org.jetbrains.kotlin.psi.KtClass; import java.util.HashSet; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FeedParser; public class JsonDtoBuilder { String json; PsiClass classUnderCaret; KtClass ktClass; DtoCreationOptionsFacade dtoCreationOptionsFacade; HashSet<NameConflictResolverCommand> nameConflictResolverCommands; HashSet<NameParserCommand> feildNameParser;
LanguageType languageType;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/FeedParser/JsonDtoBuilder.java
// Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java // public class DtoCreationOptionsFacade { // private FieldCreationStrategy fieldCreationStrategy; // private ClassCreatorStrategy classAdderStrategy; // private KotlinClassCreationStrategy kotlinClassCreationStrategy; // private AccessModifier accessModifier; // private EnumSet<FieldEncapsulationOptions> encapsulationOptionses; // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.classAdderStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, KotlinClassCreationStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.kotlinClassCreationStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public FieldCreationStrategy getFieldCreationStrategy() { // return fieldCreationStrategy; // } // // // public ClassCreatorStrategy getClassCreationStrategy() { // return classAdderStrategy; // } // // public KotlinClassCreationStrategy getKotlinClassCreationStrategy() { // return kotlinClassCreationStrategy; // } // // public AccessModifier getAccessModifier() { // return accessModifier; // } // // public void setAccessModifier(AccessModifier accessModifier) { // this.accessModifier = accessModifier; // } // // public EnumSet<FieldEncapsulationOptions> getEncapsulationOptionses() { // return encapsulationOptionses; // } // // // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NameParserCommand.java // public interface NameParserCommand { // String parseFieldName(String name); // // String undoParsing(String name); // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // }
import com.intellij.psi.PsiClass; import com.nvinayshetty.DTOnator.DtoCreationOptions.DtoCreationOptionsFacade; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.NameParserCommand; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import org.jetbrains.kotlin.psi.KtClass; import java.util.HashSet;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FeedParser; public class JsonDtoBuilder { String json; PsiClass classUnderCaret; KtClass ktClass; DtoCreationOptionsFacade dtoCreationOptionsFacade; HashSet<NameConflictResolverCommand> nameConflictResolverCommands; HashSet<NameParserCommand> feildNameParser; LanguageType languageType;
// Path: src/com/nvinayshetty/DTOnator/DtoCreationOptions/DtoCreationOptionsFacade.java // public class DtoCreationOptionsFacade { // private FieldCreationStrategy fieldCreationStrategy; // private ClassCreatorStrategy classAdderStrategy; // private KotlinClassCreationStrategy kotlinClassCreationStrategy; // private AccessModifier accessModifier; // private EnumSet<FieldEncapsulationOptions> encapsulationOptionses; // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, ClassCreatorStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.classAdderStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public DtoCreationOptionsFacade(FieldCreationStrategy fieldCreationStrategy, KotlinClassCreationStrategy classAdderStrategy, AccessModifier accessModifier, HashSet<NameConflictResolverCommand> nameConflictResolverCommands, EnumSet<FieldEncapsulationOptions> encapsulationOptionses) { // this.fieldCreationStrategy = fieldCreationStrategy; // this.kotlinClassCreationStrategy = classAdderStrategy; // this.accessModifier = accessModifier; // this.encapsulationOptionses = encapsulationOptionses; // } // // public FieldCreationStrategy getFieldCreationStrategy() { // return fieldCreationStrategy; // } // // // public ClassCreatorStrategy getClassCreationStrategy() { // return classAdderStrategy; // } // // public KotlinClassCreationStrategy getKotlinClassCreationStrategy() { // return kotlinClassCreationStrategy; // } // // public AccessModifier getAccessModifier() { // return accessModifier; // } // // public void setAccessModifier(AccessModifier accessModifier) { // this.accessModifier = accessModifier; // } // // public EnumSet<FieldEncapsulationOptions> getEncapsulationOptionses() { // return encapsulationOptionses; // } // // // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/LanguageType.java // public enum LanguageType { // JAVA, KOTLIN_VAL,KOTLIN_VAR,KOTLIN // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NameParserCommand.java // public interface NameParserCommand { // String parseFieldName(String name); // // String undoParsing(String name); // } // // Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/NameConflictResolverCommand.java // public interface NameConflictResolverCommand { // String resolve(String keyword); // } // Path: src/com/nvinayshetty/DTOnator/FeedParser/JsonDtoBuilder.java import com.intellij.psi.PsiClass; import com.nvinayshetty.DTOnator.DtoCreationOptions.DtoCreationOptionsFacade; import com.nvinayshetty.DTOnator.FieldCreator.LanguageType; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.NameConventionCommands.NameParserCommand; import com.nvinayshetty.DTOnator.nameConflictResolvers.NameConflictResolverCommand; import org.jetbrains.kotlin.psi.KtClass; import java.util.HashSet; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FeedParser; public class JsonDtoBuilder { String json; PsiClass classUnderCaret; KtClass ktClass; DtoCreationOptionsFacade dtoCreationOptionsFacade; HashSet<NameConflictResolverCommand> nameConflictResolverCommands; HashSet<NameParserCommand> feildNameParser; LanguageType languageType;
ClassNameOptions classNameOptions;
nvinayshetty/DTOnator
src/test/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixerShould.java
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixer.java // public class NamePrefixer implements NameParserCommand { // private String prefix; // // private NamePrefixer(String prefix) { // this.prefix = prefix; // } // // public static NamePrefixer prefixWith(String prefix) { // return new NamePrefixer(prefix); // } // // @Override // public String parseFieldName(String name) { // String nameINUpperCase = DtoHelper.firstetterToUpperCase(name); // return prefix + nameINUpperCase; // } // // @Override // public String undoParsing(String name) { // String unparsed = name; // if (name.startsWith(prefix)) // unparsed = name.replaceFirst(prefix, ""); // if (!new KeywordClassifier().isValidJavaIdentifier(unparsed)) // unparsed = name; // return unparsed; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // NamePrefixer that = (NamePrefixer) o; // return o.getClass().getName().equals(that.getClass().getName()); // // } // // @Override // public int hashCode() { // return this.getClass().getName().hashCode(); // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // }
import static org.junit.Assert.assertEquals; import com.nvinayshetty.DTOnator.NameConventionCommands.NamePrefixer; import com.nvinayshetty.DTOnator.Utility.DtoHelper; import org.junit.Test;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.NameConventionCommands; /** * Created by vinay on 16/8/15. */ public class NamePrefixerShould { String prefixString="m"; @Test public void prefixFieldWithTheString() { String fieldName="valid";
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixer.java // public class NamePrefixer implements NameParserCommand { // private String prefix; // // private NamePrefixer(String prefix) { // this.prefix = prefix; // } // // public static NamePrefixer prefixWith(String prefix) { // return new NamePrefixer(prefix); // } // // @Override // public String parseFieldName(String name) { // String nameINUpperCase = DtoHelper.firstetterToUpperCase(name); // return prefix + nameINUpperCase; // } // // @Override // public String undoParsing(String name) { // String unparsed = name; // if (name.startsWith(prefix)) // unparsed = name.replaceFirst(prefix, ""); // if (!new KeywordClassifier().isValidJavaIdentifier(unparsed)) // unparsed = name; // return unparsed; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // NamePrefixer that = (NamePrefixer) o; // return o.getClass().getName().equals(that.getClass().getName()); // // } // // @Override // public int hashCode() { // return this.getClass().getName().hashCode(); // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // } // Path: src/test/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixerShould.java import static org.junit.Assert.assertEquals; import com.nvinayshetty.DTOnator.NameConventionCommands.NamePrefixer; import com.nvinayshetty.DTOnator.Utility.DtoHelper; import org.junit.Test; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.NameConventionCommands; /** * Created by vinay on 16/8/15. */ public class NamePrefixerShould { String prefixString="m"; @Test public void prefixFieldWithTheString() { String fieldName="valid";
String actual= NamePrefixer.prefixWith(prefixString).parseFieldName(fieldName);
nvinayshetty/DTOnator
src/test/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixerShould.java
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixer.java // public class NamePrefixer implements NameParserCommand { // private String prefix; // // private NamePrefixer(String prefix) { // this.prefix = prefix; // } // // public static NamePrefixer prefixWith(String prefix) { // return new NamePrefixer(prefix); // } // // @Override // public String parseFieldName(String name) { // String nameINUpperCase = DtoHelper.firstetterToUpperCase(name); // return prefix + nameINUpperCase; // } // // @Override // public String undoParsing(String name) { // String unparsed = name; // if (name.startsWith(prefix)) // unparsed = name.replaceFirst(prefix, ""); // if (!new KeywordClassifier().isValidJavaIdentifier(unparsed)) // unparsed = name; // return unparsed; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // NamePrefixer that = (NamePrefixer) o; // return o.getClass().getName().equals(that.getClass().getName()); // // } // // @Override // public int hashCode() { // return this.getClass().getName().hashCode(); // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // }
import static org.junit.Assert.assertEquals; import com.nvinayshetty.DTOnator.NameConventionCommands.NamePrefixer; import com.nvinayshetty.DTOnator.Utility.DtoHelper; import org.junit.Test;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.NameConventionCommands; /** * Created by vinay on 16/8/15. */ public class NamePrefixerShould { String prefixString="m"; @Test public void prefixFieldWithTheString() { String fieldName="valid"; String actual= NamePrefixer.prefixWith(prefixString).parseFieldName(fieldName);
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixer.java // public class NamePrefixer implements NameParserCommand { // private String prefix; // // private NamePrefixer(String prefix) { // this.prefix = prefix; // } // // public static NamePrefixer prefixWith(String prefix) { // return new NamePrefixer(prefix); // } // // @Override // public String parseFieldName(String name) { // String nameINUpperCase = DtoHelper.firstetterToUpperCase(name); // return prefix + nameINUpperCase; // } // // @Override // public String undoParsing(String name) { // String unparsed = name; // if (name.startsWith(prefix)) // unparsed = name.replaceFirst(prefix, ""); // if (!new KeywordClassifier().isValidJavaIdentifier(unparsed)) // unparsed = name; // return unparsed; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // NamePrefixer that = (NamePrefixer) o; // return o.getClass().getName().equals(that.getClass().getName()); // // } // // @Override // public int hashCode() { // return this.getClass().getName().hashCode(); // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // } // Path: src/test/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixerShould.java import static org.junit.Assert.assertEquals; import com.nvinayshetty.DTOnator.NameConventionCommands.NamePrefixer; import com.nvinayshetty.DTOnator.Utility.DtoHelper; import org.junit.Test; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.NameConventionCommands; /** * Created by vinay on 16/8/15. */ public class NamePrefixerShould { String prefixString="m"; @Test public void prefixFieldWithTheString() { String fieldName="valid"; String actual= NamePrefixer.prefixWith(prefixString).parseFieldName(fieldName);
String expected=prefixString+ DtoHelper.firstetterToUpperCase(fieldName);
nvinayshetty/DTOnator
src/test/com/nvinayshetty/DTOnator/nameConflictResolvers/PrefexingConflictResolverCommandShould.java
// Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/PrefixingConflictResolverCommand.java // public class PrefixingConflictResolverCommand implements NameConflictResolverCommand { // private String prefixString; // // public PrefixingConflictResolverCommand(String prefixString) { // this.prefixString = prefixString; // } // // @Override // public String resolve(String keyword) { // return prefixString + keyword; // } // }
import com.nvinayshetty.DTOnator.nameConflictResolvers.PrefixingConflictResolverCommand; import org.junit.Test; import static junit.framework.Assert.assertEquals;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.nameConflictResolvers; /** * Created by vinay on 1/8/15. */ public class PrefexingConflictResolverCommandShould { @Test public void resolveInvalidJavaIdentifier() {
// Path: src/com/nvinayshetty/DTOnator/nameConflictResolvers/PrefixingConflictResolverCommand.java // public class PrefixingConflictResolverCommand implements NameConflictResolverCommand { // private String prefixString; // // public PrefixingConflictResolverCommand(String prefixString) { // this.prefixString = prefixString; // } // // @Override // public String resolve(String keyword) { // return prefixString + keyword; // } // } // Path: src/test/com/nvinayshetty/DTOnator/nameConflictResolvers/PrefexingConflictResolverCommandShould.java import com.nvinayshetty.DTOnator.nameConflictResolvers.PrefixingConflictResolverCommand; import org.junit.Test; import static junit.framework.Assert.assertEquals; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.nameConflictResolvers; /** * Created by vinay on 1/8/15. */ public class PrefexingConflictResolverCommandShould { @Test public void resolveInvalidJavaIdentifier() {
assertEquals("m2", new PrefixingConflictResolverCommand("m").resolve("2"));
nvinayshetty/DTOnator
src/test/com/nvinayshetty/DTOnator/fieldRepresentors/IntegerFieldRepresentorShould.java
// Path: src/com/nvinayshetty/DTOnator/FieldRepresentors/IntegerFieldRepresentor.java // public class IntegerFieldRepresentor extends FieldRepresentor { // @Override // public String getFieldRepresentationFor(AccessModifier accessModifier, String key) { // return accessModifier.getModifier() + "int" + suffix(key); // } // // @Override // protected String getKotlinValFieldRepresentationFor(AccessModifier accessModifier, String key) { // return "val " + key + " :Int"+"\n"; // } // // @Override // protected String getKotlinVarFieldRepresentationFor(AccessModifier accessModifier, String key) { // return "var " + key + " :Int"; // } // // // }
import static junit.framework.TestCase.assertEquals; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldRepresentors.IntegerFieldRepresentor; import org.junit.Test;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.fieldRepresentors; /** * Created by vinay on 1/8/15. */ public class IntegerFieldRepresentorShould { private String fieldName; @Test public void CreatePublicFieldWhenAcessModifierIsPublic() { fieldName = "valid";
// Path: src/com/nvinayshetty/DTOnator/FieldRepresentors/IntegerFieldRepresentor.java // public class IntegerFieldRepresentor extends FieldRepresentor { // @Override // public String getFieldRepresentationFor(AccessModifier accessModifier, String key) { // return accessModifier.getModifier() + "int" + suffix(key); // } // // @Override // protected String getKotlinValFieldRepresentationFor(AccessModifier accessModifier, String key) { // return "val " + key + " :Int"+"\n"; // } // // @Override // protected String getKotlinVarFieldRepresentationFor(AccessModifier accessModifier, String key) { // return "var " + key + " :Int"; // } // // // } // Path: src/test/com/nvinayshetty/DTOnator/fieldRepresentors/IntegerFieldRepresentorShould.java import static junit.framework.TestCase.assertEquals; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldRepresentors.IntegerFieldRepresentor; import org.junit.Test; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.fieldRepresentors; /** * Created by vinay on 1/8/15. */ public class IntegerFieldRepresentorShould { private String fieldName; @Test public void CreatePublicFieldWhenAcessModifierIsPublic() { fieldName = "valid";
String actual = new IntegerFieldRepresentor().getFieldRepresentationFor(AccessModifier.PUBLIC, fieldName);
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/ClassCreator/publicKotlinClassCreator.java
// Path: src/com/nvinayshetty/DTOnator/FieldCreator/ExposedGsonFieldCreator.java // public class ExposedGsonFieldCreator implements FieldCreationStrategy { // @Override // public String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver) { // return type.gsonFieldWithExposeAnnotationTemplate(languageType, accessModifier, key, parser, nameConflictResolver); // } // // @Override // public String getImportDirective() { // return "com.google.gson.annotations.Expose"; // } // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // }
import com.intellij.psi.JavaDirectoryService; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; import com.nvinayshetty.DTOnator.FieldCreator.ExposedGsonFieldCreator; import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.KtClass; import org.jetbrains.kotlin.psi.KtImportDirective; import org.jetbrains.kotlin.psi.KtPackageDirective; import org.jetbrains.kotlin.psi.KtPsiFactory; import org.jetbrains.kotlin.resolve.ImportPath;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.ClassCreator; public class publicKotlinClassCreator extends KotlinClassCreationStrategy { PsiDirectory pkgOfClassUnderCaret; public publicKotlinClassCreator(PsiDirectory aPackage) { pkgOfClassUnderCaret = aPackage; } @Override
// Path: src/com/nvinayshetty/DTOnator/FieldCreator/ExposedGsonFieldCreator.java // public class ExposedGsonFieldCreator implements FieldCreationStrategy { // @Override // public String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver) { // return type.gsonFieldWithExposeAnnotationTemplate(languageType, accessModifier, key, parser, nameConflictResolver); // } // // @Override // public String getImportDirective() { // return "com.google.gson.annotations.Expose"; // } // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // } // Path: src/com/nvinayshetty/DTOnator/ClassCreator/publicKotlinClassCreator.java import com.intellij.psi.JavaDirectoryService; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; import com.nvinayshetty.DTOnator.FieldCreator.ExposedGsonFieldCreator; import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.KtClass; import org.jetbrains.kotlin.psi.KtImportDirective; import org.jetbrains.kotlin.psi.KtPackageDirective; import org.jetbrains.kotlin.psi.KtPsiFactory; import org.jetbrains.kotlin.resolve.ImportPath; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.ClassCreator; public class publicKotlinClassCreator extends KotlinClassCreationStrategy { PsiDirectory pkgOfClassUnderCaret; public publicKotlinClassCreator(PsiDirectory aPackage) { pkgOfClassUnderCaret = aPackage; } @Override
public void addClass(KtClass psiClass, FieldCreationStrategy fieldCreationStrategy) {
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/ClassCreator/publicKotlinClassCreator.java
// Path: src/com/nvinayshetty/DTOnator/FieldCreator/ExposedGsonFieldCreator.java // public class ExposedGsonFieldCreator implements FieldCreationStrategy { // @Override // public String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver) { // return type.gsonFieldWithExposeAnnotationTemplate(languageType, accessModifier, key, parser, nameConflictResolver); // } // // @Override // public String getImportDirective() { // return "com.google.gson.annotations.Expose"; // } // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // }
import com.intellij.psi.JavaDirectoryService; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; import com.nvinayshetty.DTOnator.FieldCreator.ExposedGsonFieldCreator; import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.KtClass; import org.jetbrains.kotlin.psi.KtImportDirective; import org.jetbrains.kotlin.psi.KtPackageDirective; import org.jetbrains.kotlin.psi.KtPsiFactory; import org.jetbrains.kotlin.resolve.ImportPath;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.ClassCreator; public class publicKotlinClassCreator extends KotlinClassCreationStrategy { PsiDirectory pkgOfClassUnderCaret; public publicKotlinClassCreator(PsiDirectory aPackage) { pkgOfClassUnderCaret = aPackage; } @Override public void addClass(KtClass psiClass, FieldCreationStrategy fieldCreationStrategy) { String name = psiClass.getName() + ".kt"; KtPsiFactory ktPsiFactory = new KtPsiFactory(psiClass.getProject()); String qualifiedName = JavaDirectoryService.getInstance().getPackage(pkgOfClassUnderCaret).getQualifiedName(); KtPackageDirective packageDirective = ktPsiFactory.createPackageDirective(new FqName(qualifiedName)); PsiFile file = pkgOfClassUnderCaret.createFile(name); file.add(packageDirective); if(!fieldCreationStrategy.getImportDirective().isEmpty()) { FqName fqName = new FqName(fieldCreationStrategy.getImportDirective()); ImportPath importPath = new ImportPath(fqName, false); KtImportDirective importDirective = ktPsiFactory.createImportDirective(importPath); psiClass.getContainingKtFile().getImportList().add(importDirective);
// Path: src/com/nvinayshetty/DTOnator/FieldCreator/ExposedGsonFieldCreator.java // public class ExposedGsonFieldCreator implements FieldCreationStrategy { // @Override // public String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver) { // return type.gsonFieldWithExposeAnnotationTemplate(languageType, accessModifier, key, parser, nameConflictResolver); // } // // @Override // public String getImportDirective() { // return "com.google.gson.annotations.Expose"; // } // } // // Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // } // Path: src/com/nvinayshetty/DTOnator/ClassCreator/publicKotlinClassCreator.java import com.intellij.psi.JavaDirectoryService; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; import com.nvinayshetty.DTOnator.FieldCreator.ExposedGsonFieldCreator; import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.KtClass; import org.jetbrains.kotlin.psi.KtImportDirective; import org.jetbrains.kotlin.psi.KtPackageDirective; import org.jetbrains.kotlin.psi.KtPsiFactory; import org.jetbrains.kotlin.resolve.ImportPath; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.ClassCreator; public class publicKotlinClassCreator extends KotlinClassCreationStrategy { PsiDirectory pkgOfClassUnderCaret; public publicKotlinClassCreator(PsiDirectory aPackage) { pkgOfClassUnderCaret = aPackage; } @Override public void addClass(KtClass psiClass, FieldCreationStrategy fieldCreationStrategy) { String name = psiClass.getName() + ".kt"; KtPsiFactory ktPsiFactory = new KtPsiFactory(psiClass.getProject()); String qualifiedName = JavaDirectoryService.getInstance().getPackage(pkgOfClassUnderCaret).getQualifiedName(); KtPackageDirective packageDirective = ktPsiFactory.createPackageDirective(new FqName(qualifiedName)); PsiFile file = pkgOfClassUnderCaret.createFile(name); file.add(packageDirective); if(!fieldCreationStrategy.getImportDirective().isEmpty()) { FqName fqName = new FqName(fieldCreationStrategy.getImportDirective()); ImportPath importPath = new ImportPath(fqName, false); KtImportDirective importDirective = ktPsiFactory.createImportDirective(importPath); psiClass.getContainingKtFile().getImportList().add(importDirective);
if (fieldCreationStrategy instanceof ExposedGsonFieldCreator) {
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/ClassCreator/InnerKotlinClassCreator.java
// Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // }
import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import org.jetbrains.kotlin.psi.KtClass;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.ClassCreator; public class InnerKotlinClassCreator extends KotlinClassCreationStrategy { private KtClass classUnderCaret; public InnerKotlinClassCreator(KtClass psiClass) { this.classUnderCaret = psiClass; } @Override
// Path: src/com/nvinayshetty/DTOnator/FieldCreator/FieldCreationStrategy.java // public interface FieldCreationStrategy { // String getFieldFor(LanguageType languageType, FieldRepresentor type, AccessModifier accessModifier, String key, FieldNameParser parser, NameConflictResolver nameConflictResolver); // // String getImportDirective(); // // } // Path: src/com/nvinayshetty/DTOnator/ClassCreator/InnerKotlinClassCreator.java import com.nvinayshetty.DTOnator.FieldCreator.FieldCreationStrategy; import org.jetbrains.kotlin.psi.KtClass; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.ClassCreator; public class InnerKotlinClassCreator extends KotlinClassCreationStrategy { private KtClass classUnderCaret; public InnerKotlinClassCreator(KtClass psiClass) { this.classUnderCaret = psiClass; } @Override
public void addClass(KtClass aClass, FieldCreationStrategy fieldCreationStrategy) {
nvinayshetty/DTOnator
src/test/com/nvinayshetty/DTOnator/fieldRepresentors/BooleanFieldRepresentorShould.java
// Path: src/com/nvinayshetty/DTOnator/FieldRepresentors/BooleanFieldRepresentor.java // public class BooleanFieldRepresentor extends FieldRepresentor { // @Override // public String getFieldRepresentationFor(AccessModifier accessModifier, String key) { // return accessModifier.getModifier() + "boolean" + suffix(key); // } // // @Override // protected String getKotlinValFieldRepresentationFor(AccessModifier accessModifier, String key) { // return "val " + key + " :Boolean"+"\n"; // } // // @Override // protected String getKotlinVarFieldRepresentationFor(AccessModifier accessModifier, String key) { // return "var " + key + " :Boolean"; // } // // // }
import static junit.framework.TestCase.assertEquals; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldRepresentors.BooleanFieldRepresentor; import org.junit.Test;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.fieldRepresentors; /** * Created by vinay on 1/8/15. */ public class BooleanFieldRepresentorShould { private String fieldName = "valid"; @Test public void CreatePublicFieldWhenAcessModifierIsPublic() {
// Path: src/com/nvinayshetty/DTOnator/FieldRepresentors/BooleanFieldRepresentor.java // public class BooleanFieldRepresentor extends FieldRepresentor { // @Override // public String getFieldRepresentationFor(AccessModifier accessModifier, String key) { // return accessModifier.getModifier() + "boolean" + suffix(key); // } // // @Override // protected String getKotlinValFieldRepresentationFor(AccessModifier accessModifier, String key) { // return "val " + key + " :Boolean"+"\n"; // } // // @Override // protected String getKotlinVarFieldRepresentationFor(AccessModifier accessModifier, String key) { // return "var " + key + " :Boolean"; // } // // // } // Path: src/test/com/nvinayshetty/DTOnator/fieldRepresentors/BooleanFieldRepresentorShould.java import static junit.framework.TestCase.assertEquals; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.FieldRepresentors.BooleanFieldRepresentor; import org.junit.Test; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package test.com.nvinayshetty.DTOnator.fieldRepresentors; /** * Created by vinay on 1/8/15. */ public class BooleanFieldRepresentorShould { private String fieldName = "valid"; @Test public void CreatePublicFieldWhenAcessModifierIsPublic() {
String actual = new BooleanFieldRepresentor().getFieldRepresentationFor(AccessModifier.PUBLIC, fieldName);
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/FieldRepresentors/JsonArrayRepresentor.java
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // }
import javax.annotation.Nonnull; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.Utility.DtoHelper;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FieldRepresentors; /** * Created by vinay on 12/7/15. */ public class JsonArrayRepresentor extends FieldRepresentor { private String dataType; private int depth;
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // } // Path: src/com/nvinayshetty/DTOnator/FieldRepresentors/JsonArrayRepresentor.java import javax.annotation.Nonnull; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.Utility.DtoHelper; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.FieldRepresentors; /** * Created by vinay on 12/7/15. */ public class JsonArrayRepresentor extends FieldRepresentor { private String dataType; private int depth;
private ClassNameOptions classNameOptions;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/FieldRepresentors/JsonArrayRepresentor.java
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // }
import javax.annotation.Nonnull; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.Utility.DtoHelper;
} @Override public String getFieldRepresentationFor(AccessModifier accessModifier, String key) { return accessModifier.getModifier() + "java.util.List<" + getSimpleNameForList(dataType) + ">" + suffix(key); } @Override protected String getKotlinValFieldRepresentationFor(AccessModifier accessModifier, String key) { String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : ""; return "val " + key +clasNameOption+ " :List<" + getSimpleNameForList(dataType) + ">"; } @Override protected String getKotlinVarFieldRepresentationFor(AccessModifier accessModifier, String key) { String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : ""; return "var " + key+clasNameOption + " :List<" + getSimpleNameForList(dataType) + ">"; } public void setClassNameOption(ClassNameOptions classNameOptions) { this.classNameOptions = classNameOptions; } private String getSimpleNameForList(String simpleName) { String name = ""; for (int i = 1; i < depth; i++) { name += "java.util.List<"; } String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : "";
// Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/ClassName/ClassNameOptions.java // public enum ClassNameOptions { // Bean("Bean"),Entity("Entity"),None("None"); // // private String bean; // // ClassNameOptions(String bean) { // this.bean = bean; // } // // public String getName() { // return bean; // } // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // } // Path: src/com/nvinayshetty/DTOnator/FieldRepresentors/JsonArrayRepresentor.java import javax.annotation.Nonnull; import com.nvinayshetty.DTOnator.FieldCreator.AccessModifier; import com.nvinayshetty.DTOnator.NameConventionCommands.ClassName.ClassNameOptions; import com.nvinayshetty.DTOnator.Utility.DtoHelper; } @Override public String getFieldRepresentationFor(AccessModifier accessModifier, String key) { return accessModifier.getModifier() + "java.util.List<" + getSimpleNameForList(dataType) + ">" + suffix(key); } @Override protected String getKotlinValFieldRepresentationFor(AccessModifier accessModifier, String key) { String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : ""; return "val " + key +clasNameOption+ " :List<" + getSimpleNameForList(dataType) + ">"; } @Override protected String getKotlinVarFieldRepresentationFor(AccessModifier accessModifier, String key) { String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : ""; return "var " + key+clasNameOption + " :List<" + getSimpleNameForList(dataType) + ">"; } public void setClassNameOption(ClassNameOptions classNameOptions) { this.classNameOptions = classNameOptions; } private String getSimpleNameForList(String simpleName) { String name = ""; for (int i = 1; i < depth; i++) { name += "java.util.List<"; } String clasNameOption = (classNameOptions != null) ? classNameOptions.getName() : "";
name += DtoHelper.firstetterToUpperCase(simpleName)+clasNameOption;
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixer.java
// Path: src/com/nvinayshetty/DTOnator/FeedValidator/KeywordClassifier.java // public class KeywordClassifier { // private HashSet<String> javaKeywords = new HashSet<String>(); // // public void initKeywords() { // javaKeywords.add("abstract"); // javaKeywords.add("continue"); // javaKeywords.add("for"); // javaKeywords.add("new"); // javaKeywords.add("switch"); // javaKeywords.add("assert"); // javaKeywords.add("default"); // javaKeywords.add("goto"); // javaKeywords.add("package"); // javaKeywords.add("synchronized"); // javaKeywords.add("boolean"); // javaKeywords.add("do"); // javaKeywords.add("if"); // javaKeywords.add("private"); // javaKeywords.add("this"); // javaKeywords.add("byte"); // javaKeywords.add("break"); // javaKeywords.add("double"); // javaKeywords.add("implements"); // javaKeywords.add("protected"); // javaKeywords.add("throw"); // javaKeywords.add("else"); // javaKeywords.add("import"); // javaKeywords.add("public"); // javaKeywords.add("throws"); // javaKeywords.add("case"); // javaKeywords.add("enum"); // javaKeywords.add("instanceof"); // javaKeywords.add("return"); // javaKeywords.add("transient"); // javaKeywords.add("catch"); // javaKeywords.add("char"); // javaKeywords.add("extends"); // javaKeywords.add("int"); // javaKeywords.add("short"); // javaKeywords.add("try"); // javaKeywords.add("final"); // javaKeywords.add("interface"); // javaKeywords.add("static"); // javaKeywords.add("void"); // javaKeywords.add("class"); // javaKeywords.add("finally"); // javaKeywords.add("long"); // javaKeywords.add("strictfp"); // javaKeywords.add("volatile"); // javaKeywords.add("const"); // javaKeywords.add("float"); // javaKeywords.add("native"); // javaKeywords.add("super"); // javaKeywords.add("while"); // javaKeywords.add("true"); // javaKeywords.add("false"); // javaKeywords.add("null"); // } // // public boolean isValidJavaIdentifier(String string) { // initKeywords(); // if (string.isEmpty()) { // return false; // } // if (!Character.isJavaIdentifierStart(string.charAt(0))) { // return false; // } // for (int i = 1; i < string.length(); i++) { // if (!Character.isJavaIdentifierPart(string.charAt(i))) { // return false; // } // } // return !javaKeywords.contains(string); // } // // // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // }
import com.nvinayshetty.DTOnator.FeedValidator.KeywordClassifier; import com.nvinayshetty.DTOnator.Utility.DtoHelper;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.NameConventionCommands; /** * Created by vinay on 12/7/15. */ public class NamePrefixer implements NameParserCommand { private String prefix; private NamePrefixer(String prefix) { this.prefix = prefix; } public static NamePrefixer prefixWith(String prefix) { return new NamePrefixer(prefix); } @Override public String parseFieldName(String name) {
// Path: src/com/nvinayshetty/DTOnator/FeedValidator/KeywordClassifier.java // public class KeywordClassifier { // private HashSet<String> javaKeywords = new HashSet<String>(); // // public void initKeywords() { // javaKeywords.add("abstract"); // javaKeywords.add("continue"); // javaKeywords.add("for"); // javaKeywords.add("new"); // javaKeywords.add("switch"); // javaKeywords.add("assert"); // javaKeywords.add("default"); // javaKeywords.add("goto"); // javaKeywords.add("package"); // javaKeywords.add("synchronized"); // javaKeywords.add("boolean"); // javaKeywords.add("do"); // javaKeywords.add("if"); // javaKeywords.add("private"); // javaKeywords.add("this"); // javaKeywords.add("byte"); // javaKeywords.add("break"); // javaKeywords.add("double"); // javaKeywords.add("implements"); // javaKeywords.add("protected"); // javaKeywords.add("throw"); // javaKeywords.add("else"); // javaKeywords.add("import"); // javaKeywords.add("public"); // javaKeywords.add("throws"); // javaKeywords.add("case"); // javaKeywords.add("enum"); // javaKeywords.add("instanceof"); // javaKeywords.add("return"); // javaKeywords.add("transient"); // javaKeywords.add("catch"); // javaKeywords.add("char"); // javaKeywords.add("extends"); // javaKeywords.add("int"); // javaKeywords.add("short"); // javaKeywords.add("try"); // javaKeywords.add("final"); // javaKeywords.add("interface"); // javaKeywords.add("static"); // javaKeywords.add("void"); // javaKeywords.add("class"); // javaKeywords.add("finally"); // javaKeywords.add("long"); // javaKeywords.add("strictfp"); // javaKeywords.add("volatile"); // javaKeywords.add("const"); // javaKeywords.add("float"); // javaKeywords.add("native"); // javaKeywords.add("super"); // javaKeywords.add("while"); // javaKeywords.add("true"); // javaKeywords.add("false"); // javaKeywords.add("null"); // } // // public boolean isValidJavaIdentifier(String string) { // initKeywords(); // if (string.isEmpty()) { // return false; // } // if (!Character.isJavaIdentifierStart(string.charAt(0))) { // return false; // } // for (int i = 1; i < string.length(); i++) { // if (!Character.isJavaIdentifierPart(string.charAt(i))) { // return false; // } // } // return !javaKeywords.contains(string); // } // // // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // } // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixer.java import com.nvinayshetty.DTOnator.FeedValidator.KeywordClassifier; import com.nvinayshetty.DTOnator.Utility.DtoHelper; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.NameConventionCommands; /** * Created by vinay on 12/7/15. */ public class NamePrefixer implements NameParserCommand { private String prefix; private NamePrefixer(String prefix) { this.prefix = prefix; } public static NamePrefixer prefixWith(String prefix) { return new NamePrefixer(prefix); } @Override public String parseFieldName(String name) {
String nameINUpperCase = DtoHelper.firstetterToUpperCase(name);
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixer.java
// Path: src/com/nvinayshetty/DTOnator/FeedValidator/KeywordClassifier.java // public class KeywordClassifier { // private HashSet<String> javaKeywords = new HashSet<String>(); // // public void initKeywords() { // javaKeywords.add("abstract"); // javaKeywords.add("continue"); // javaKeywords.add("for"); // javaKeywords.add("new"); // javaKeywords.add("switch"); // javaKeywords.add("assert"); // javaKeywords.add("default"); // javaKeywords.add("goto"); // javaKeywords.add("package"); // javaKeywords.add("synchronized"); // javaKeywords.add("boolean"); // javaKeywords.add("do"); // javaKeywords.add("if"); // javaKeywords.add("private"); // javaKeywords.add("this"); // javaKeywords.add("byte"); // javaKeywords.add("break"); // javaKeywords.add("double"); // javaKeywords.add("implements"); // javaKeywords.add("protected"); // javaKeywords.add("throw"); // javaKeywords.add("else"); // javaKeywords.add("import"); // javaKeywords.add("public"); // javaKeywords.add("throws"); // javaKeywords.add("case"); // javaKeywords.add("enum"); // javaKeywords.add("instanceof"); // javaKeywords.add("return"); // javaKeywords.add("transient"); // javaKeywords.add("catch"); // javaKeywords.add("char"); // javaKeywords.add("extends"); // javaKeywords.add("int"); // javaKeywords.add("short"); // javaKeywords.add("try"); // javaKeywords.add("final"); // javaKeywords.add("interface"); // javaKeywords.add("static"); // javaKeywords.add("void"); // javaKeywords.add("class"); // javaKeywords.add("finally"); // javaKeywords.add("long"); // javaKeywords.add("strictfp"); // javaKeywords.add("volatile"); // javaKeywords.add("const"); // javaKeywords.add("float"); // javaKeywords.add("native"); // javaKeywords.add("super"); // javaKeywords.add("while"); // javaKeywords.add("true"); // javaKeywords.add("false"); // javaKeywords.add("null"); // } // // public boolean isValidJavaIdentifier(String string) { // initKeywords(); // if (string.isEmpty()) { // return false; // } // if (!Character.isJavaIdentifierStart(string.charAt(0))) { // return false; // } // for (int i = 1; i < string.length(); i++) { // if (!Character.isJavaIdentifierPart(string.charAt(i))) { // return false; // } // } // return !javaKeywords.contains(string); // } // // // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // }
import com.nvinayshetty.DTOnator.FeedValidator.KeywordClassifier; import com.nvinayshetty.DTOnator.Utility.DtoHelper;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.NameConventionCommands; /** * Created by vinay on 12/7/15. */ public class NamePrefixer implements NameParserCommand { private String prefix; private NamePrefixer(String prefix) { this.prefix = prefix; } public static NamePrefixer prefixWith(String prefix) { return new NamePrefixer(prefix); } @Override public String parseFieldName(String name) { String nameINUpperCase = DtoHelper.firstetterToUpperCase(name); return prefix + nameINUpperCase; } @Override public String undoParsing(String name) { String unparsed = name; if (name.startsWith(prefix)) unparsed = name.replaceFirst(prefix, "");
// Path: src/com/nvinayshetty/DTOnator/FeedValidator/KeywordClassifier.java // public class KeywordClassifier { // private HashSet<String> javaKeywords = new HashSet<String>(); // // public void initKeywords() { // javaKeywords.add("abstract"); // javaKeywords.add("continue"); // javaKeywords.add("for"); // javaKeywords.add("new"); // javaKeywords.add("switch"); // javaKeywords.add("assert"); // javaKeywords.add("default"); // javaKeywords.add("goto"); // javaKeywords.add("package"); // javaKeywords.add("synchronized"); // javaKeywords.add("boolean"); // javaKeywords.add("do"); // javaKeywords.add("if"); // javaKeywords.add("private"); // javaKeywords.add("this"); // javaKeywords.add("byte"); // javaKeywords.add("break"); // javaKeywords.add("double"); // javaKeywords.add("implements"); // javaKeywords.add("protected"); // javaKeywords.add("throw"); // javaKeywords.add("else"); // javaKeywords.add("import"); // javaKeywords.add("public"); // javaKeywords.add("throws"); // javaKeywords.add("case"); // javaKeywords.add("enum"); // javaKeywords.add("instanceof"); // javaKeywords.add("return"); // javaKeywords.add("transient"); // javaKeywords.add("catch"); // javaKeywords.add("char"); // javaKeywords.add("extends"); // javaKeywords.add("int"); // javaKeywords.add("short"); // javaKeywords.add("try"); // javaKeywords.add("final"); // javaKeywords.add("interface"); // javaKeywords.add("static"); // javaKeywords.add("void"); // javaKeywords.add("class"); // javaKeywords.add("finally"); // javaKeywords.add("long"); // javaKeywords.add("strictfp"); // javaKeywords.add("volatile"); // javaKeywords.add("const"); // javaKeywords.add("float"); // javaKeywords.add("native"); // javaKeywords.add("super"); // javaKeywords.add("while"); // javaKeywords.add("true"); // javaKeywords.add("false"); // javaKeywords.add("null"); // } // // public boolean isValidJavaIdentifier(String string) { // initKeywords(); // if (string.isEmpty()) { // return false; // } // if (!Character.isJavaIdentifierStart(string.charAt(0))) { // return false; // } // for (int i = 1; i < string.length(); i++) { // if (!Character.isJavaIdentifierPart(string.charAt(i))) { // return false; // } // } // return !javaKeywords.contains(string); // } // // // } // // Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // } // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/NamePrefixer.java import com.nvinayshetty.DTOnator.FeedValidator.KeywordClassifier; import com.nvinayshetty.DTOnator.Utility.DtoHelper; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.NameConventionCommands; /** * Created by vinay on 12/7/15. */ public class NamePrefixer implements NameParserCommand { private String prefix; private NamePrefixer(String prefix) { this.prefix = prefix; } public static NamePrefixer prefixWith(String prefix) { return new NamePrefixer(prefix); } @Override public String parseFieldName(String name) { String nameINUpperCase = DtoHelper.firstetterToUpperCase(name); return prefix + nameINUpperCase; } @Override public String undoParsing(String name) { String unparsed = name; if (name.startsWith(prefix)) unparsed = name.replaceFirst(prefix, "");
if (!new KeywordClassifier().isValidJavaIdentifier(unparsed))
nvinayshetty/DTOnator
src/com/nvinayshetty/DTOnator/NameConventionCommands/CamelCase.java
// Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // }
import com.nvinayshetty.DTOnator.Utility.DtoHelper; import org.apache.commons.lang.WordUtils;
/* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.NameConventionCommands; /** * Created by vinay on 18/7/15. */ public class CamelCase implements NameParserCommand { @Override public String parseFieldName(String name) { String capitalized = name; if (name.contains(" ")) { capitalized = WordUtils.capitalizeFully(name); } if (name.contains("_")) capitalized = WordUtils.capitalizeFully(capitalized, new char[]{'_'}); else capitalized = WordUtils.capitalizeFully(capitalized);
// Path: src/com/nvinayshetty/DTOnator/Utility/DtoHelper.java // public class DtoHelper { // public static String firstetterToUpperCase(String key) { // return key.substring(0, 1).toUpperCase() + key.substring(1); // } // // public static String firstetterToLowerCase(String key) { // return key.substring(0, 1).toLowerCase() + key.substring(1); // } // } // Path: src/com/nvinayshetty/DTOnator/NameConventionCommands/CamelCase.java import com.nvinayshetty.DTOnator.Utility.DtoHelper; import org.apache.commons.lang.WordUtils; /* * Copyright (C) 2015 Vinaya Prasad N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.nvinayshetty.DTOnator.NameConventionCommands; /** * Created by vinay on 18/7/15. */ public class CamelCase implements NameParserCommand { @Override public String parseFieldName(String name) { String capitalized = name; if (name.contains(" ")) { capitalized = WordUtils.capitalizeFully(name); } if (name.contains("_")) capitalized = WordUtils.capitalizeFully(capitalized, new char[]{'_'}); else capitalized = WordUtils.capitalizeFully(capitalized);
String javaConvention = DtoHelper.firstetterToLowerCase(capitalized);