Create a new GPS {@code Speed} object.

@param speed the GPS speed value
@param unit the speed unit
@return a new GPS {@code Speed} object
@throws NullPointerException if the given speed {@code unit} is
{@code null}
9328
public static Speed of(final double speed, final Unit unit) {
		requireNonNull(unit);
		return new Speed(Unit.METERS_PER_SECOND.convert(speed, unit));
	}
590275
function(points, callback, fromIndex, toIndex) {
	var i, len, index, currentDistance, currentSpeed, fastestSpeed = 0, slowestSpeed = 100000000;
	var result;
	len = points.length - 1;
	i = 0;
	if(fromIndex && fromIndex > 0 && fromIndex < len) {
		i = fromIndex;
	}
	if(toIndex && toIndex < len) {
		len = toIndex;
	}
	if(points.length < 2 || len - i < 2) {
		return callback(new Error('Result can not be calculated properly with data points less than 2'), null);
	}

	try {
		result = new TrackingResult();
		index = 0;
		result.points[index] = Trackpoint.copy(points[i]);
		result.points[index].distance = 0;
		for(; i < len; i++, index++) {
			result.points[index + 1] = Trackpoint.copy(points[i + 1]);
			currentDistance = distance.getDistance(result.points[index].lng, result.points[index].lat, result.points[index + 1].lng, result.points[index + 1].lat);
			currentSpeed = speed.calculateSpeed(currentDistance, result.points[index].time, result.points[index + 1].time);
			result.totalDistance += currentDistance;
			result.points[index + 1].distance = result.points[index].distance + currentDistance;
			result.points[index + 1].speed = currentSpeed;
			if(currentSpeed > fastestSpeed) {
				fastestSpeed = currentSpeed;
			}
			if(currentSpeed < slowestSpeed) {
				slowestSpeed = currentSpeed;
			}
		}
		result.points[0].speed = result.points[1].speed;
		result.averageSpeed = speed.calculateSpeed(result.totalDistance, result.points[0].time, result.points[index].time);
		result.fastestSpeed = fastestSpeed;
		result.slowestSpeed = slowestSpeed;
		result.totalTime = time.getDiffInSecs(result.points[0].time, result.points[index].time);
		callback(null, result);
	} catch(e) {
		callback(e, null);
	}
}
716789
public static Executor delayedExecutor(long delay, TimeUnit unit) {
        if (unit == null)
            throw new NullPointerException();
        return new DelayedExecutor(delay, unit, ASYNC_POOL);
    }
708441
@SuppressWarnings( "unchecked" )
    protected PackageMetadata createPackageMetadata( CompilationUnit unit ) {
        PackageMetadata packageMetadata = null;
        List<Annotation> annotations = null;
        PackageDeclaration packageDeclaration = unit.getPackage();
        if (packageDeclaration != null) {
            annotations = packageDeclaration.annotations();
            packageMetadata = new PackageMetadata(JavaMetadataUtil.getName(unit.getPackage().getName()));
            if (!annotations.isEmpty()) {
                for (Object object : annotations) {
                    packageMetadata.getAnnotations().add(createAnnotationMetadataFor((Annotation)object));
                }
            }
        }
        return packageMetadata;
    }
301074
private void init(final long qty, final TimeUnit unit) {
        long millis = unit.convert(qty);
        seconds = TimeUnit.MILLISECOND.convert(millis, TimeUnit.SECOND) % 60;
        minutes = TimeUnit.MILLISECOND.convert(millis, TimeUnit.MINUTE) % 60;
        hours = TimeUnit.MILLISECOND.convert(millis, TimeUnit.HOUR) % 24;
        days = TimeUnit.MILLISECOND.convert(millis, TimeUnit.DAY);
    }
180713
private SimpleOrderedMap<Object> createPosition(ComponentPosition position,
      Boolean encode) throws IOException {
    // System.out.println("Create stats position " + position.dataType + " "
    // + position.statsType + " " + position.statsItems + " --- " + encode);
    SimpleOrderedMap<Object> mtasPositionResponse = new SimpleOrderedMap<>();
    mtasPositionResponse.add("key", position.key);
    MtasSolrMtasResult data = new MtasSolrMtasResult(position.dataCollector,
        position.dataType, position.statsType, position.statsItems, null, null);
    if (encode) {
      mtasPositionResponse.add("_encoded_data",
          MtasSolrResultUtil.encode(data));
    } else {
      mtasPositionResponse.add(position.dataCollector.getCollectorType(), data);
      MtasSolrResultUtil.rewrite(mtasPositionResponse, searchComponent);
    }
    return mtasPositionResponse;
  }
323344
public void setTimeUnit(com.google.api.ads.admanager.axis.v201808.TimeUnit timeUnit) {
        this.timeUnit = timeUnit;
    }
1211938
public static Timer newTimer(String name, TimeUnit unit) {
    return new BasicTimer(MonitorConfig.builder(name).build(), unit);
  }
746550
public boolean setFanSpeed(int speed) throws CommandExecutionException {
        if (speed < 0 || speed > 100) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
        JSONArray params = new JSONArray();
        params.put(speed);
        return sendOk("set_custom_mode", params);
    }
1195788
static ClockNormalizer ofOnlyMode(ClockUnit unit) {

        ClockNormalizer ret = MAP_ONLY.get(unit);

        if (ret == null) {
            throw new IllegalArgumentException(unit.name());
        }

        return ret;

    }
837856
@Around("execution(* *(..)) && @annotation(TimerJ)")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        String methodName = MethodSignature.class.cast(point.getSignature()).getMethod().getName();
        String methodArgs = point.getArgs().toString();
        MetricRegistry metricRegistry = Metrics.getRegistry();
        Timer timer;

        String metricName = "Starting method "+methodName + "at "+System.nanoTime();
        synchronized (this) {
            if(metricRegistry.getTimers().containsKey(methodName)){
                timer = metricRegistry.getTimers().get(metricName);
            }
            else{
                timer = metricRegistry.register(metricName, new Timer());
            }
        }
        Timer.Context before = timer.time();
        Object result = point.proceed();
        long timeAfter = before.stop();

        logger.debug("Method " + methodName + " with args " + methodArgs + " executed in " + timeAfter + " ns");

        return result;
    }
1212504
public static <V> AtomicReference<V> newReference(@Nullable V initialValue) {
    return new AtomicReference<V>(initialValue);
  }
272905
def create(*units):
    """"""
    ret = []
    for unit in units: # implemented using sc2simulator.ScenarioUnit
        x, y = unit.position[:2]
        pt = Point2D(x=x, y=y)
        unit.tag = 0 # forget any tag because a new unit will be created
        new = DebugCommand(create_unit=DebugCreateUnit(
            unit_type   = unit.code,
            owner       = unit.owner,
            pos         = pt,
            quantity    = 1,
        ))
        ret.append(new)
    return ret
1046337
public void initialize(UnitType unitType, double unitLength, Coordinate position) {
		if (null == unitType) {
			throw new IllegalArgumentException("please provide a unitType");
		}

		this.unitType = unitType;
		this.unitLength = unitLength;

		backGround = new Rectangle((null == getId() ? "" : getId() + "-bg"));
		backGround.setBounds(new Bbox(0, 0, 5, MARKER_HEIGHT + 2 * VERTICAL_PADDING));
		backGround.setStyle(STYLE_BACKGROUND);
		leftMarker = new Rectangle((null == getId() ? "" : getId() + "-lm"));
		leftMarker.setStyle(STYLE_MARKER);
		leftMarker.setBounds(new Bbox(0, 0, 1, MARKER_HEIGHT));

		rightMarker = new Rectangle((null == getId() ? "" : getId() + "-rm"));
		rightMarker.setStyle(STYLE_MARKER);
		rightMarker.setBounds(new Bbox(0, 0, 1, MARKER_HEIGHT));
		bottomLine = new Rectangle((null == getId() ? "" : getId() + "-bm"));
		bottomLine.setStyle(STYLE_MARKER);
		bottomLine.setBounds(new Bbox(0, 0, 0, 1));
		distance = new Text((null == getId() ? "" : getId() + "-text"));
		distance.setStyle(STYLE_FONT);

		dummy = new Rectangle(getId() + "-dummy");
		dummy.setStyle(new ShapeStyle("#FFFFFF", 0, "#FFFFFF", 0, 0));
		dummy.setBounds(new Bbox(0, 0, 1, 1));
	}
1167925
@Pure
	public static double fromMetersPerSecond(double value, SpeedUnit outputUnit) {
		switch (outputUnit) {
		case KILOMETERS_PER_HOUR:
			return value / 3.6;
		case MILLIMETERS_PER_SECOND:
			return value * 1000.;
		case METERS_PER_SECOND:
		default:
		}
		return value;
	}
719633
def set_unit(self, unit):
        
        # accept all core time units
        if unit is None or (isinstance(unit, units.NamedUnit) and
                            unit.physical_type == 'time'):
            self._unit = unit
            return
        # convert float to custom unit in seconds
        if isinstance(unit, Number):
            unit = units.Unit(unit * units.second)
        # otherwise, should be able to convert to a time unit
        try:
            unit = units.Unit(unit)
        except ValueError as exc:
            # catch annoying plurals
            try:
                unit = units.Unit(str(unit).rstrip('s'))
            except ValueError:
                raise exc
        # decompose and check that it's actually a time unit
        dec = unit.decompose()
        if dec.bases != [units.second]:
            raise ValueError("Cannot set GPS unit to %s" % unit)
        # check equivalent units
        for other in TIME_UNITS:
            if other.decompose().scale == dec.scale:
                self._unit = other
                return
        raise ValueError("Unrecognised unit: %s" % unit)
49304
public static UnitRequest create(Class<? extends Unit> unitClass) {
        Unit unit = LocalUnitsManager.getUnitByUnitClass(unitClass);
        return create(unit.getGroup().getName(), unit.getName());
    }