Skip to content

[Feature request] create class without builder with internal constructor #25

@RingerJK

Description

@RingerJK
/**
 * Represents a person.
 * @property name The full name.
 * @property nickname The nickname.
 * @property age The age.
 */
@DataCompatInternal
private data class PersonData(val name: String, val nickname: String? = null, val age: Int)
/**
 * Represents a person.
 * @property name The full name.
 * @property nickname The nickname.
 * @property age The age.
 */
public class Person internal constructor(
  public val name: String,
  public val nickname: String?,
  public val age: Int
) {
  public override fun toString() = // toString

  public override fun equals(other: Any?): Boolean = // equals

  public override fun hashCode(): Int = // hashCode
}

It can be used for classes that are public, but mustn't be created outside of a module

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions