diff --git a/Examples/Cocoa/Sources/Objective_C/Board.m b/Examples/Cocoa/Sources/Objective_C/Board.m index ab7e9902..c587cf40 100644 --- a/Examples/Cocoa/Sources/Objective_C/Board.m +++ b/Examples/Cocoa/Sources/Objective_C/Board.m @@ -15,6 +15,7 @@ unsigned int BoardDirtyPropertyCounts:1; unsigned int BoardDirtyPropertyCreatedAt:1; unsigned int BoardDirtyPropertyCreator:1; + unsigned int BoardDirtyPropertyCreatorURL:1; unsigned int BoardDirtyPropertyDescriptionText:1; unsigned int BoardDirtyPropertyImage:1; unsigned int BoardDirtyPropertyName:1; @@ -107,6 +108,15 @@ - (instancetype)initWithModelDictionary:(NS_VALID_UNTIL_END_OF_SCOPE NSDictionar self->_boardDirtyProperties.BoardDirtyPropertyCreator = 1; } } + { + __unsafe_unretained id value = modelDictionary[@"creator_url"]; // Collection will retain. + if (value != nil) { + if (value != (id)kCFNull) { + self->_creatorURL = [NSURL URLWithString:value]; + } + self->_boardDirtyProperties.BoardDirtyPropertyCreatorURL = 1; + } + } { __unsafe_unretained id value = modelDictionary[@"description"]; // Collection will retain. if (value != nil) { @@ -163,6 +173,7 @@ - (instancetype)initWithBuilder:(BoardBuilder *)builder initType:(PlankModelInit _counts = builder.counts; _createdAt = builder.createdAt; _creator = builder.creator; + _creatorURL = builder.creatorURL; _descriptionText = builder.descriptionText; _image = builder.image; _name = builder.name; @@ -176,7 +187,7 @@ - (instancetype)initWithBuilder:(BoardBuilder *)builder initType:(PlankModelInit - (NSString *)debugDescription { NSArray *parentDebugDescription = [[super debugDescription] componentsSeparatedByString:@"\n"]; - NSMutableArray *descriptionFields = [NSMutableArray arrayWithCapacity:8]; + NSMutableArray *descriptionFields = [NSMutableArray arrayWithCapacity:9]; [descriptionFields addObject:parentDebugDescription]; struct BoardDirtyProperties props = _boardDirtyProperties; if (props.BoardDirtyPropertyContributors) { @@ -191,6 +202,9 @@ - (NSString *)debugDescription if (props.BoardDirtyPropertyCreator) { [descriptionFields addObject:[@"_creator = " stringByAppendingFormat:@"%@", _creator]]; } + if (props.BoardDirtyPropertyCreatorURL) { + [descriptionFields addObject:[@"_creatorURL = " stringByAppendingFormat:@"%@", _creatorURL]]; + } if (props.BoardDirtyPropertyDescriptionText) { [descriptionFields addObject:[@"_descriptionText = " stringByAppendingFormat:@"%@", _descriptionText]]; } @@ -234,6 +248,7 @@ - (BOOL)isEqualToBoard:(Board *)anObject (_counts == anObject.counts || [_counts isEqualToDictionary:anObject.counts]) && (_createdAt == anObject.createdAt || [_createdAt isEqualToDate:anObject.createdAt]) && (_creator == anObject.creator || [_creator isEqualToDictionary:anObject.creator]) && + (_creatorURL == anObject.creatorURL || [_creatorURL isEqual:anObject.creatorURL]) && (_descriptionText == anObject.descriptionText || [_descriptionText isEqualToString:anObject.descriptionText]) && (_image == anObject.image || [_image isEqual:anObject.image]) && (_name == anObject.name || [_name isEqualToString:anObject.name]) && @@ -248,6 +263,7 @@ - (NSUInteger)hash [_counts hash], [_createdAt hash], [_creator hash], + [_creatorURL hash], [_descriptionText hash], [_image hash], [_name hash], @@ -307,6 +323,13 @@ - (NSDictionary *)dictionaryObjectRepresentation [dict setObject:[NSNull null] forKey:@"creator"]; } } + if (_boardDirtyProperties.BoardDirtyPropertyCreatorURL) { + if (_creatorURL != nil) { + [dict setObject:[_creatorURL absoluteString] forKey:@"creator_url"]; + } else { + [dict setObject:[NSNull null] forKey:@"creator_url"]; + } + } if (_boardDirtyProperties.BoardDirtyPropertyDescriptionText) { if (_descriptionText != nil) { [dict setObject:_descriptionText forKey:@"description"]; @@ -353,6 +376,10 @@ - (BOOL)isCreatorSet { return _boardDirtyProperties.BoardDirtyPropertyCreator == 1; } +- (BOOL)isCreatorUrlSet +{ + return _boardDirtyProperties.BoardDirtyPropertyCreatorURL == 1; +} - (BOOL)isDescriptionTextSet { return _boardDirtyProperties.BoardDirtyPropertyDescriptionText == 1; @@ -386,6 +413,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder _counts = [aDecoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSNumber class]]] forKey:@"counts"]; _createdAt = [aDecoder decodeObjectOfClass:[NSDate class] forKey:@"created_at"]; _creator = [aDecoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class]]] forKey:@"creator"]; + _creatorURL = [aDecoder decodeObjectOfClass:[NSURL class] forKey:@"creator_url"]; _descriptionText = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"description"]; _image = [aDecoder decodeObjectOfClass:[Image class] forKey:@"image"]; _name = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"name"]; @@ -394,6 +422,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder _boardDirtyProperties.BoardDirtyPropertyCounts = [aDecoder decodeIntForKey:@"counts_dirty_property"] & 0x1; _boardDirtyProperties.BoardDirtyPropertyCreatedAt = [aDecoder decodeIntForKey:@"created_at_dirty_property"] & 0x1; _boardDirtyProperties.BoardDirtyPropertyCreator = [aDecoder decodeIntForKey:@"creator_dirty_property"] & 0x1; + _boardDirtyProperties.BoardDirtyPropertyCreatorURL = [aDecoder decodeIntForKey:@"creator_url_dirty_property"] & 0x1; _boardDirtyProperties.BoardDirtyPropertyDescriptionText = [aDecoder decodeIntForKey:@"description_dirty_property"] & 0x1; _boardDirtyProperties.BoardDirtyPropertyImage = [aDecoder decodeIntForKey:@"image_dirty_property"] & 0x1; _boardDirtyProperties.BoardDirtyPropertyName = [aDecoder decodeIntForKey:@"name_dirty_property"] & 0x1; @@ -410,6 +439,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder [aCoder encodeObject:self.counts forKey:@"counts"]; [aCoder encodeObject:self.createdAt forKey:@"created_at"]; [aCoder encodeObject:self.creator forKey:@"creator"]; + [aCoder encodeObject:self.creatorURL forKey:@"creator_url"]; [aCoder encodeObject:self.descriptionText forKey:@"description"]; [aCoder encodeObject:self.image forKey:@"image"]; [aCoder encodeObject:self.name forKey:@"name"]; @@ -418,6 +448,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder [aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyCounts forKey:@"counts_dirty_property"]; [aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyCreatedAt forKey:@"created_at_dirty_property"]; [aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyCreator forKey:@"creator_dirty_property"]; + [aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyCreatorURL forKey:@"creator_url_dirty_property"]; [aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyDescriptionText forKey:@"description_dirty_property"]; [aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyImage forKey:@"image_dirty_property"]; [aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyName forKey:@"name_dirty_property"]; @@ -443,6 +474,9 @@ - (instancetype)initWithModel:(Board *)modelObject if (boardDirtyProperties.BoardDirtyPropertyCreator) { _creator = modelObject.creator; } + if (boardDirtyProperties.BoardDirtyPropertyCreatorURL) { + _creatorURL = modelObject.creatorURL; + } if (boardDirtyProperties.BoardDirtyPropertyDescriptionText) { _descriptionText = modelObject.descriptionText; } @@ -479,6 +513,9 @@ - (void)mergeWithModel:(Board *)modelObject if (modelObject.boardDirtyProperties.BoardDirtyPropertyCreator) { builder.creator = modelObject.creator; } + if (modelObject.boardDirtyProperties.BoardDirtyPropertyCreatorURL) { + builder.creatorURL = modelObject.creatorURL; + } if (modelObject.boardDirtyProperties.BoardDirtyPropertyDescriptionText) { builder.descriptionText = modelObject.descriptionText; } @@ -517,6 +554,11 @@ - (void)setCreator:(NSDictionary *)creator _creator = creator; _boardDirtyProperties.BoardDirtyPropertyCreator = 1; } +- (void)setCreatorURL:(NSURL *)creatorURL +{ + _creatorURL = [creatorURL copy]; + _boardDirtyProperties.BoardDirtyPropertyCreatorURL = 1; +} - (void)setDescriptionText:(NSString *)descriptionText { _descriptionText = [descriptionText copy]; diff --git a/Examples/Cocoa/Sources/Objective_C/include/Board.h b/Examples/Cocoa/Sources/Objective_C/include/Board.h index edab955a..e6b0d6cf 100644 --- a/Examples/Cocoa/Sources/Objective_C/include/Board.h +++ b/Examples/Cocoa/Sources/Objective_C/include/Board.h @@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nullable, nonatomic, strong, readonly) NSDictionary * counts; @property (nullable, nonatomic, copy, readonly) NSDate * createdAt; @property (nullable, nonatomic, strong, readonly) NSDictionary * creator; +@property (nullable, nonatomic, copy, readonly) NSURL * creatorURL; @property (nullable, nonatomic, copy, readonly) NSString * descriptionText; @property (nonnull, nonatomic, strong, readonly) Image * image; @property (nullable, nonatomic, copy, readonly) NSString * name; @@ -34,6 +35,7 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)isCountsSet; - (BOOL)isCreatedAtSet; - (BOOL)isCreatorSet; +- (BOOL)isCreatorUrlSet; - (BOOL)isDescriptionTextSet; - (BOOL)isImageSet; - (BOOL)isNameSet; @@ -45,6 +47,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nullable, nonatomic, strong, readwrite) NSDictionary * counts; @property (nullable, nonatomic, copy, readwrite) NSDate * createdAt; @property (nullable, nonatomic, strong, readwrite) NSDictionary * creator; +@property (nullable, nonatomic, copy, readwrite) NSURL * creatorURL; @property (nullable, nonatomic, copy, readwrite) NSString * descriptionText; @property (nonnull, nonatomic, strong, readwrite) Image * image; @property (nullable, nonatomic, copy, readwrite) NSString * name; diff --git a/Examples/JS/flow/BoardType.js b/Examples/JS/flow/BoardType.js index 38933155..8304f6ee 100644 --- a/Examples/JS/flow/BoardType.js +++ b/Examples/JS/flow/BoardType.js @@ -16,6 +16,7 @@ export type BoardType = $Shape<{| +counts: ?{ +[string]: number } /* Integer */, +created_at: ?PlankDate, +creator: ?{ +[string]: string }, + +creator_url: ?PlankURI, +description: ?string, +image: ImageType, +name: ?string, diff --git a/Examples/Java/Sources/Board.java b/Examples/Java/Sources/Board.java index a6d64120..8faa6b6f 100644 --- a/Examples/Java/Sources/Board.java +++ b/Examples/Java/Sources/Board.java @@ -37,6 +37,7 @@ public class Board { @SerializedName("counts") private @Nullable Map counts; @SerializedName("created_at") private @Nullable Date createdAt; @SerializedName("creator") private @Nullable Map creator; + @SerializedName("creator_url") private @Nullable String creatorURL; @SerializedName("description") private @Nullable String description; @SerializedName("image") private @NonNull Image image; @SerializedName("name") private @Nullable String name; @@ -47,10 +48,11 @@ public class Board { static final private int COUNTS_SET = 1 << 2; static final private int CREATED_AT_SET = 1 << 3; static final private int CREATOR_SET = 1 << 4; - static final private int DESCRIPTION_SET = 1 << 5; - static final private int IMAGE_SET = 1 << 6; - static final private int NAME_SET = 1 << 7; - static final private int URL_SET = 1 << 8; + static final private int CREATOR_URL_SET = 1 << 5; + static final private int DESCRIPTION_SET = 1 << 6; + static final private int IMAGE_SET = 1 << 7; + static final private int NAME_SET = 1 << 8; + static final private int URL_SET = 1 << 9; private int _bits = 0; @@ -60,6 +62,7 @@ private Board( @Nullable Map counts, @Nullable Date createdAt, @Nullable Map creator, + @Nullable String creatorURL, @Nullable String description, @NonNull Image image, @Nullable String name, @@ -71,6 +74,7 @@ private Board( this.counts = counts; this.createdAt = createdAt; this.creator = creator; + this.creatorURL = creatorURL; this.description = description; this.image = image; this.name = name; @@ -106,6 +110,7 @@ public boolean equals(Object o) { Objects.equals(this.counts, that.counts) && Objects.equals(this.createdAt, that.createdAt) && Objects.equals(this.creator, that.creator) && + Objects.equals(this.creatorURL, that.creatorURL) && Objects.equals(this.description, that.description) && Objects.equals(this.image, that.image) && Objects.equals(this.name, that.name) && @@ -119,6 +124,7 @@ public int hashCode() { counts, createdAt, creator, + creatorURL, description, image, name, @@ -145,6 +151,10 @@ public int hashCode() { return this.creator; } + public @Nullable String getCreatorURL() { + return this.creatorURL; + } + public @Nullable String getDescription() { return this.description; } @@ -181,6 +191,10 @@ public boolean getCreatorIsSet() { return (this._bits & CREATOR_SET) == CREATOR_SET; } + public boolean getCreatorURLIsSet() { + return (this._bits & CREATOR_URL_SET) == CREATOR_URL_SET; + } + public boolean getDescriptionIsSet() { return (this._bits & DESCRIPTION_SET) == DESCRIPTION_SET; } @@ -204,6 +218,7 @@ public static class Builder { @SerializedName("counts") private @Nullable Map counts; @SerializedName("created_at") private @Nullable Date createdAt; @SerializedName("creator") private @Nullable Map creator; + @SerializedName("creator_url") private @Nullable String creatorURL; @SerializedName("description") private @Nullable String description; @SerializedName("image") private @NonNull Image image; @SerializedName("name") private @Nullable String name; @@ -220,6 +235,7 @@ private Builder(@NonNull Board model) { this.counts = model.counts; this.createdAt = model.createdAt; this.creator = model.creator; + this.creatorURL = model.creatorURL; this.description = model.description; this.image = model.image; this.name = model.name; @@ -257,6 +273,12 @@ public Builder setCreator(@Nullable Map value) { return this; } + public Builder setCreatorURL(@Nullable String value) { + this.creatorURL = value; + this._bits |= CREATOR_URL_SET; + return this; + } + public Builder setDescription(@Nullable String value) { this.description = value; this._bits |= DESCRIPTION_SET; @@ -301,6 +323,10 @@ public Builder setUrl(@Nullable String value) { return this.creator; } + public @Nullable String getCreatorURL() { + return this.creatorURL; + } + public @Nullable String getDescription() { return this.description; } @@ -324,6 +350,7 @@ public Board build() { this.counts, this.createdAt, this.creator, + this.creatorURL, this.description, this.image, this.name, @@ -348,6 +375,9 @@ public void mergeFrom(Board model) { if (model.getCreatorIsSet()) { this.creator = model.creator; } + if (model.getCreatorURLIsSet()) { + this.creatorURL = model.creatorURL; + } if (model.getDescriptionIsSet()) { this.description = model.description; } @@ -426,6 +456,9 @@ public Board read(JsonReader reader) throws IOException { case ("creator"): builder.setCreator(map_String__String_TypeAdapter.read(reader)); break; + case ("creator_url"): + builder.setCreatorURL(stringTypeAdapter.read(reader)); + break; case ("description"): builder.setDescription(stringTypeAdapter.read(reader)); break; diff --git a/Examples/PDK/board.json b/Examples/PDK/board.json index cabd57bb..2c79c6f2 100644 --- a/Examples/PDK/board.json +++ b/Examples/PDK/board.json @@ -11,6 +11,10 @@ "type": "string", "format": "uri" }, + "creator_url" : { + "type": "string", + "format": "uri" + }, "description" : { "type": "string" }, "creator": { "type": "object", diff --git a/Sources/Core/JavaModelRenderer.swift b/Sources/Core/JavaModelRenderer.swift index 41f1787d..ba8e4fc2 100644 --- a/Sources/Core/JavaModelRenderer.swift +++ b/Sources/Core/JavaModelRenderer.swift @@ -176,7 +176,7 @@ public struct JavaModelRenderer: JavaFileRenderer { func renderBuilderSetters(modifiers: JavaModifier = [.public]) -> [JavaIR.Method] { let setters = transitiveProperties.map { param, schemaObj in - JavaIR.method(modifiers, "Builder set\(Languages.java.snakeCaseToCamelCase(param))(\(self.typeFromSchema(param, schemaObj)) value)") { [ + JavaIR.method(modifiers, "Builder set\(Languages.java.snakeCaseToCapitalizedPropertyName(param))(\(self.typeFromSchema(param, schemaObj)) value)") { [ "this." + Languages.java.snakeCaseToPropertyName(param) + " = value;", "this._bits |= " + param.uppercased() + "_SET;", "return this;",