org.codehaus.jackson.annotate.JsonCreator Java Examples

The following examples show how to use org.codehaus.jackson.annotate.JsonCreator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ColumnMapperBigInteger.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a new {@link ColumnMapperBigDecimal} using the specified max number of digits.
 *
 * @param digits The max number of digits. If {@code null}, the {@link #DEFAULT_DIGITS} will be used.
 */
@JsonCreator
public ColumnMapperBigInteger(@JsonProperty("digits") Integer digits) {
    super(new AbstractType<?>[]{AsciiType.instance,
                                UTF8Type.instance,
                                Int32Type.instance,
                                LongType.instance,
                                IntegerType.instance}, new AbstractType[]{});

    if (digits != null && digits <= 0) {
        throw new IllegalArgumentException("Positive digits required");
    }

    this.digits = digits == null ? DEFAULT_DIGITS : digits;
    complement = BigInteger.valueOf(10).pow(this.digits).subtract(BigInteger.valueOf(1));
    BigInteger maxValue = complement.multiply(BigInteger.valueOf(2));
    hexDigits = encode(maxValue).length();
}
 
Example #2
Source File: WebhookInfo.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
@JsonCreator
public WebhookInfo(
     @JsonProperty("headers") Map<String, String> headers,
     @JsonProperty("targetURL") String targetURL,
     @JsonProperty("timeoutMsec") Integer timeout,
     @JsonProperty("statuses") List<String> statuses) throws URISyntaxException {

  this.headers = ImmutableMap.copyOf(headers);
  this.targetURI = new URI(requireNonNull(targetURL));
  this.connectTimeoutMsec = requireNonNull(timeout);
  this.whitelistedStatuses = IS_ALL_WHITELISTED.apply(statuses) ? Optional.empty()
      : Optional.ofNullable(statuses).map(
          s -> ImmutableList.copyOf(s.stream()
              .map(ScheduleStatus::valueOf)
              .collect(Collectors.toList())));
}
 
Example #3
Source File: ResourceTemplateMetaData.java    From jwala with Apache License 2.0 6 votes vote down vote up
@JsonCreator
public ResourceTemplateMetaData(@JsonProperty("templateName") final String templateName,
                                @JsonProperty("contentType") final MediaType contentType,
                                @JsonProperty("deployFileName") final String deployFileName,
                                @JsonProperty("deployPath") final String deployPath,
                                @JsonProperty("entity") final Entity entity,
                                @JsonProperty("unpack") final Boolean unpack,
                                @JsonProperty("overwrite") Boolean overwrite,
                                @JsonProperty("hotDeploy") Boolean hotDeploy) {
    this.templateName = templateName;
    this.contentType = contentType;
    this.deployFileName = deployFileName;
    this.deployPath = deployPath;
    this.entity = entity;
    this.unpack = unpack == null ? false : unpack;
    this.overwrite = overwrite == null ? true : overwrite;
    this.hotDeploy = hotDeploy == null ? false : hotDeploy;
}
 
Example #4
Source File: ColumnMapperDate.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a new {@link ColumnMapperDate} using the specified pattern.
 *
 * @param pattern The {@link SimpleDateFormat} pattern to be used.
 */
@JsonCreator
public ColumnMapperDate(@JsonProperty("pattern") String pattern) {
    super(new AbstractType<?>[]{AsciiType.instance,
                                UTF8Type.instance,
                                Int32Type.instance,
                                LongType.instance,
                                IntegerType.instance,
                                FloatType.instance,
                                DoubleType.instance,
                                DecimalType.instance,
                                TimestampType.instance},
          new AbstractType[]{LongType.instance, TimestampType.instance});
    this.pattern = pattern == null ? DEFAULT_PATTERN : pattern;
    concurrentDateFormat = new ThreadLocal<DateFormat>() {
        @Override
        protected DateFormat initialValue() {
            return new SimpleDateFormat(ColumnMapperDate.this.pattern);
        }
    };
}
 
Example #5
Source File: ColumnMapperText.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a new {@link ColumnMapperText} using the specified Lucene {@link Analyzer}.
 *
 * @param analyzer The Lucene {@link Analyzer} to be used.
 */
@JsonCreator
public ColumnMapperText(@JsonProperty("analyzer") String analyzer) {
    super(new AbstractType<?>[]{AsciiType.instance,
                                UTF8Type.instance,
                                Int32Type.instance,
                                LongType.instance,
                                IntegerType.instance,
                                FloatType.instance,
                                DoubleType.instance,
                                BooleanType.instance,
                                UUIDType.instance,
                                TimeUUIDType.instance,
                                TimestampType.instance,
                                BytesType.instance,
                                InetAddressType.instance}, new AbstractType[]{});
    this.analyzer = analyzer == null ? PreBuiltAnalyzers.DEFAULT.name() : analyzer;

}
 
Example #6
Source File: FuzzyCondition.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a new {@link FuzzyCondition}.
 *
 * @param boost          The boost for this query clause. Documents matching this clause will (in addition to the
 *                       normal weightings) have their score multiplied by {@code boost}. If {@code null}, then
 *                       {@link #DEFAULT_BOOST} is used as default.
 * @param field          The field name.
 * @param value          The field fuzzy value.
 * @param maxEdits       Must be >= 0 and <= {@link LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE}.
 * @param prefixLength   Length of common (non-fuzzy) prefix
 * @param maxExpansions  The maximum number of terms to match. If this number is greater than {@link
 *                       BooleanQuery#getMaxClauseCount} when the query is rewritten, then the maxClauseCount will
 *                       be used instead.
 * @param transpositions True if transpositions should be treated as a primitive edit operation. If this is false,
 *                       comparisons will implement the classic Levenshtein algorithm.
 */
@JsonCreator
public FuzzyCondition(@JsonProperty("boost") Float boost,
                      @JsonProperty("field") String field,
                      @JsonProperty("value") String value,
                      @JsonProperty("max_edits") Integer maxEdits,
                      @JsonProperty("prefix_length") Integer prefixLength,
                      @JsonProperty("max_expansions") Integer maxExpansions,
                      @JsonProperty("transpositions") Boolean transpositions) {
    super(boost);

    this.field = field;
    this.value = value;
    this.maxEdits = maxEdits == null ? DEFAULT_MAX_EDITS : maxEdits;
    this.prefixLength = prefixLength == null ? DEFAULT_PREFIX_LENGTH : prefixLength;
    this.maxExpansions = maxExpansions == null ? DEFAULT_MAX_EXPANSIONS : maxExpansions;
    this.transpositions = transpositions == null ? DEFAULT_TRANSPOSITIONS : transpositions;
}
 
Example #7
Source File: TestTopStateHandoffMetrics.java    From helix with Apache License 2.0 6 votes vote down vote up
@JsonCreator
public TestCaseConfig(
    @JsonProperty("InitialCurrentStates") Map<String, CurrentStateInfo> initial,
    @JsonProperty("MissingTopStates") Map<String, CurrentStateInfo> missing,
    @JsonProperty("HandoffCurrentStates") Map<String, CurrentStateInfo> handoff,
    @JsonProperty("Duration") long d,
    @JsonProperty("HelixLatency") long helix,
    @JsonProperty("IsGraceful") boolean graceful
) {
  initialCurrentStates = initial;
  currentStateWithMissingTopState = missing;
  finalCurrentState = handoff;
  duration = d;
  helixLatency = helix;
  isGraceful = graceful;
}
 
Example #8
Source File: FlowKey.java    From hraven with Apache License 2.0 5 votes vote down vote up
@JsonCreator
public FlowKey(@JsonProperty("cluster") String cluster,
               @JsonProperty("userName") String userName,
               @JsonProperty("appId") String appId,
               @JsonProperty("runId") long runId) {
  super(cluster, userName, appId);
  this.runId = runId;
}
 
Example #9
Source File: Schema.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a new {@code ColumnsMapper} for the specified getAnalyzer and cell mappers.
 *
 * @param columnMappers   The {@link Column} mappers to be used.
 * @param analyzers        The {@link AnalyzerBuilder}s to be used.
 * @param defaultAnalyzer The name of the class of the getAnalyzer to be used.
 */
@JsonCreator
public Schema(@JsonProperty("fields") Map<String, ColumnMapper> columnMappers,
              @JsonProperty("analyzers") Map<String, AnalyzerBuilder> analyzers,
              @JsonProperty("default_analyzer") String defaultAnalyzer) {

    this.mapping = new Mapping(columnMappers);
    this.analysis = new Analysis(analyzers);
    this.defaultAnalyzer = analysis.getDefaultAnalyzer(defaultAnalyzer);
    this.analyzer = mapping.getAnalyzer(this.defaultAnalyzer, analysis);
}
 
Example #10
Source File: QualifiedJobId.java    From hraven with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 * 
 * @param cluster
 * @param jobId
 */
@JsonCreator
public QualifiedJobId(@JsonProperty("cluster") String cluster,
                      @JsonProperty("jobId") String jobId) {
  super(jobId);
  this.cluster = (cluster != null ? cluster.trim() : "");
}
 
Example #11
Source File: JobKey.java    From hraven with Apache License 2.0 5 votes vote down vote up
@JsonCreator
public JobKey(@JsonProperty("cluster") String cluster,
              @JsonProperty("userName") String userName,
              @JsonProperty("appId") String appId,
              @JsonProperty("runId") long runId,
              @JsonProperty("jobId") JobId jobId) {
  this(new QualifiedJobId(cluster, jobId), userName, appId, runId);
}
 
Example #12
Source File: AppKey.java    From hraven with Apache License 2.0 5 votes vote down vote up
@JsonCreator
public AppKey(@JsonProperty("cluster") String cluster, @JsonProperty("userName") String userName,
    @JsonProperty("appId") String appId) {
  this.cluster = cluster;
  this.userName = (null == userName) ? Constants.UNKNOWN : userName.trim();
  this.appId = (null == appId) ? Constants.UNKNOWN : appId.trim();
}
 
Example #13
Source File: ColumnMapperBigDecimal.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a new {@link ColumnMapperBigDecimal} using the specified max number of digits for the integer and decimal
 * parts.
 *
 * @param integerDigits The max number of digits for the integer part. If {@code null}, the {@link
 *                      #DEFAULT_INTEGER_DIGITS} will be used.
 * @param decimalDigits The max number of digits for the decimal part. If {@code null}, the {@link
 *                      #DEFAULT_DECIMAL_DIGITS} will be used.
 */
@JsonCreator
public ColumnMapperBigDecimal(@JsonProperty("integer_digits") Integer integerDigits,
                              @JsonProperty("decimal_digits") Integer decimalDigits) {
    super(new AbstractType<?>[]{AsciiType.instance,
                                UTF8Type.instance,
                                Int32Type.instance,
                                LongType.instance,
                                IntegerType.instance,
                                FloatType.instance,
                                DoubleType.instance,
                                DecimalType.instance}, new AbstractType[]{});

    // Setup integer part mapping
    if (integerDigits != null && integerDigits <= 0) {
        throw new IllegalArgumentException("Positive integer part digits required");
    }
    this.integerDigits = integerDigits == null ? DEFAULT_INTEGER_DIGITS : integerDigits;

    // Setup decimal part mapping
    if (decimalDigits != null && decimalDigits <= 0) {
        throw new IllegalArgumentException("Positive decimal part digits required");
    }
    this.decimalDigits = decimalDigits == null ? DEFAULT_DECIMAL_DIGITS : decimalDigits;

    int totalDigits = this.integerDigits + this.decimalDigits;
    BigDecimal divisor = BigDecimal.valueOf(10).pow(this.decimalDigits);
    BigDecimal dividend = BigDecimal.valueOf(10).pow(totalDigits).subtract(BigDecimal.valueOf(1));
    complement = dividend.divide(divisor);
}
 
Example #14
Source File: Flow.java    From hraven with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 * 
 * @param key
 */
@JsonCreator
public Flow(@JsonProperty("flowKey") FlowKey key) {
  this.key = key;
  // default flow name to appId
  if (this.key != null) {
    this.flowName = this.key.getAppId();
    this.userName = this.key.getUserName();
  }
}
 
Example #15
Source File: JobId.java    From hraven with Apache License 2.0 5 votes vote down vote up
@JsonCreator
public JobId(@JsonProperty("jobIdString") String jobId) {
  if (jobId != null) {
    String[] elts = jobId.trim().split(JOB_ID_SEP);
    try {
      this.jobEpoch = Long.parseLong(elts[1]);
      this.jobSequence = Long.parseLong(elts[2]);
    } catch (Exception e) {
      throw new IllegalArgumentException("Invalid job ID '"+jobId+
          "', must be in the format 'job_[0-9]+_[0-9]+'");
    }
  }
}
 
Example #16
Source File: HdfsStatsKey.java    From hraven with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new HdfsStatsKey from the given parameters
 *
 * @param QualifiedPathKey The combined cluster + path
 * @param encodedRunId inverted run timestamp
 */
@JsonCreator
public HdfsStatsKey(@JsonProperty("pathKey") QualifiedPathKey pathKey,
              @JsonProperty("encodedRunId") long encodedRunId) {
  this.pathKey = pathKey;
  this.encodedRunId = encodedRunId;
}
 
Example #17
Source File: ColumnMapperInteger.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a new {@link ColumnMapperInteger} using the specified boost.
 *
 * @param boost The boost to be used.
 */
@JsonCreator
public ColumnMapperInteger(@JsonProperty("boost") Float boost) {
    super(new AbstractType<?>[]{AsciiType.instance,
                                UTF8Type.instance,
                                Int32Type.instance,
                                LongType.instance,
                                IntegerType.instance,
                                FloatType.instance,
                                DoubleType.instance,
                                DecimalType.instance}, new AbstractType[]{Int32Type.instance});
    this.boost = boost == null ? DEFAULT_BOOST : boost;
}
 
Example #18
Source File: ColumnMapperDouble.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a new {@link ColumnMapperDouble} using the specified boost.
 *
 * @param boost The boost to be used.
 */
@JsonCreator
public ColumnMapperDouble(@JsonProperty("boost") Float boost) {
    super(new AbstractType<?>[]{AsciiType.instance,
                                UTF8Type.instance,
                                Int32Type.instance,
                                LongType.instance,
                                IntegerType.instance,
                                FloatType.instance,
                                DoubleType.instance,
                                DecimalType.instance}, new AbstractType[]{DoubleType.instance});
    this.boost = boost == null ? DEFAULT_BOOST : boost;
}
 
Example #19
Source File: GeoRectangle.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a new {@link GeoRectangle} defined by the specified geographical positions.
 *
 * @param minLongitude The minimum longitude in the rectangle to be built.
 * @param maxLongitude The maximum longitude in the rectangle to be built.
 * @param minLatitude  The minimum latitude in the rectangle to be built.
 * @param maxLatitude  The maximum latitude in the rectangle to be built.
 */
@JsonCreator
public GeoRectangle(@JsonProperty("min_longitude") double minLongitude,
                    @JsonProperty("max_longitude") double maxLongitude,
                    @JsonProperty("min_latitude") double minLatitude,
                    @JsonProperty("max_latitude") double maxLatitude) {
    checkLongitude(minLongitude);
    checkLongitude(maxLongitude);
    checkLatitude(minLatitude);
    checkLatitude(maxLatitude);
    this.minLongitude = minLongitude;
    this.maxLongitude = maxLongitude;
    this.minLatitude = minLatitude;
    this.maxLatitude = maxLatitude;
}
 
Example #20
Source File: BooleanCondition.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new {@link BooleanCondition} compound by the specified {@link Condition}s.
 *
 * @param boost  The boost for this query clause. Documents matching this clause will (in addition to the normal
 *               weightings) have their score multiplied by {@code boost}. If {@code null}, then {@link
 *               #DEFAULT_BOOST} is used as default.
 * @param must   the mandatory {@link Condition}s.
 * @param should the optional {@link Condition}s.
 * @param not    the mandatory not {@link Condition}s.
 */
@JsonCreator
public BooleanCondition(@JsonProperty("boost") Float boost,
                        @JsonProperty("must") List<Condition> must,
                        @JsonProperty("should") List<Condition> should,
                        @JsonProperty("not") List<Condition> not) {
    super(boost);
    this.must = must == null ? new LinkedList<Condition>() : must;
    this.should = should == null ? new LinkedList<Condition>() : should;
    this.not = not == null ? new LinkedList<Condition>() : not;
}
 
Example #21
Source File: SmokeCOAlarm.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
@JsonCreator
public static ColorState forValue(String v) {
    for (ColorState cs : ColorState.values()) {
        if (cs.state.equals(v)) {
            return cs;
        }
    }
    throw new IllegalArgumentException("Invalid color_state: " + v);
}
 
Example #22
Source File: LuceneCondition.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor using the field name and the value to be matched.
 *
 * @param boost        The boost for this query clause. Documents matching this clause will (in addition to the
 *                     normal weightings) have their score multiplied by {@code boost}. If {@code null}, then {@link
 *                     #DEFAULT_BOOST} is used as default.
 * @param defaultField the default field name.
 * @param query        the Lucene Query Syntax query.
 */
@JsonCreator
public LuceneCondition(@JsonProperty("boost") Float boost,
                       @JsonProperty("default_field") String defaultField,
                       @JsonProperty("query") String query) {
    super(boost);

    this.query = query;
    this.defaultField = defaultField == null ? DEFAULT_FIELD : defaultField;
}
 
Example #23
Source File: PhraseCondition.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor using the field name and the value to be matched.
 *
 * @param boost  The boost for this query clause. Documents matching this clause will (in addition to the normal
 *               weightings) have their score multiplied by {@code boost}. If {@code null}, then {@link
 *               #DEFAULT_BOOST} is used as default.
 * @param field  The name of the field to be matched.
 * @param values The phrase terms to be matched.
 * @param slop   The number of other words permitted between words in phrase.
 */
@JsonCreator
public PhraseCondition(@JsonProperty("boost") Float boost,
                       @JsonProperty("field") String field,
                       @JsonProperty("values") List<String> values,
                       @JsonProperty("slop") Integer slop) {
    super(boost);

    this.field = field;
    this.values = values;
    this.slop = slop == null ? DEFAULT_SLOP : slop;
}
 
Example #24
Source File: Thermostat.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
@JsonCreator
public static HvacMode forValue(String v) {
    for (HvacMode hm : HvacMode.values()) {
        if (hm.mode.equals(v)) {
            return hm;
        }
    }
    throw new IllegalArgumentException("Invalid hvac_mode: " + v);
}
 
Example #25
Source File: Search.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new {@link Search} composed by the specified querying and filtering conditions.
 *
 * @param queryCondition  The {@link Condition} for querying, maybe {@code null} meaning no querying.
 * @param filterCondition The {@link Condition} for filtering, maybe {@code null} meaning no filtering.
 * @param sort            The {@link Sort} for the query. Note that is the order in which the data will be read
 *                        before querying, not the order of the results after querying.
 */
@JsonCreator
public Search(@JsonProperty("query") Condition queryCondition,
              @JsonProperty("filter") Condition filterCondition,
              @JsonProperty("sort") Sort sort) {
    this.queryCondition = queryCondition;
    this.filterCondition = filterCondition;
    this.sort = sort;
}
 
Example #26
Source File: TierInfo.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@JsonCreator
public TierInfo(
    @JsonProperty("preemptible") boolean preemptible,
    @JsonProperty("revocable") boolean revocable) {

  this.preemptible = preemptible;
  this.revocable = revocable;
}
 
Example #27
Source File: ControlPlugFunction.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
@JsonCreator
public static PlugState forValue(String v) {
    for (PlugState ps : PlugState.values()) {
        if (ps.state.equals(v)) {
            return ps;
        }
    }
    throw new IllegalArgumentException("Invalid plug state: " + v);
}
 
Example #28
Source File: Structure.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
@JsonCreator
public static WwnSecurityState forValue(String v) {
    for (WwnSecurityState s : WwnSecurityState.values()) {
        if (s.state.equals(v)) {
            return s;
        }
    }
    throw new IllegalArgumentException("Invalid state: " + v);
}
 
Example #29
Source File: GeoShapeCondition.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor using the field name and the value to be matched.
 *
 * @param boost The boost for this query clause. Documents matching this clause will (in addition to the normal
 *              weightings) have their score multiplied by {@code boost}. If {@code null}, then {@link
 *              #DEFAULT_BOOST} is used as default.
 * @param field The name of the field to be matched.
 * @param shape The shape to be matched.
 */
@JsonCreator
public GeoShapeCondition(@JsonProperty("boost") Float boost,
                         @JsonProperty("field") String field,
                         @JsonProperty("operator") GeoOperator operator,
                         @JsonProperty("shape") GeoShape shape) {
    super(boost);
    this.field = field;
    this.shape = shape;
    this.operator = operator;
}
 
Example #30
Source File: WildcardCondition.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor using the field name and the value to be matched.
 *
 * @param boost The boost for this query clause. Documents matching this clause will (in addition to the normal
 *              weightings) have their score multiplied by {@code boost}. If {@code null}, then {@link
 *              #DEFAULT_BOOST} is used as default.
 * @param field The name of the field to be matched.
 * @param value The wildcard expression to be matched.
 */
@JsonCreator
public WildcardCondition(@JsonProperty("boost") Float boost,
                         @JsonProperty("field") String field,
                         @JsonProperty("value") String value) {
    super(boost);

    this.field = field;
    this.value = value;
}