Dear Kotlin community, Is it possible to convert t...
# getting-started
j
Dear Kotlin community, Is it possible to convert the following java annotations to kotlin? I tried to make it w/o any luck. I thought @JvmField would be of any help, but wasn’t.
Copy code
public class Profiles {

  @Target(ElementType.TYPE)
  @Retention(RetentionPolicy.RUNTIME)
  @Profile(Service1MockedProfile.NAME)
  public @interface Service1MockedProfile {

    String NAME = “Service1MockedProfile”;
  }

  @Target(ElementType.TYPE)
  @Retention(RetentionPolicy.RUNTIME)
  @Profile(Service2MockedProfile.NAME)
  @interface Service2MockedProfile {

    String NAME = “Service2MockedProfile”;
  }
}

@Service
@Profiles.Service1MockedProfile
class MyService {}

@ActiveProfiles(profiles = {Service1MockedProfile.NAME})
class MyServiceTest {}
o
Please use triple backticks to quote long code. Thanks!
j
Copy code
public class Profiles {

 @Target(ElementType.TYPE)
 @Retention(RetentionPolicy.RUNTIME)
 @Profile(Service1MockedProfile.NAME)
 public @interface Service1MockedProfile {

   String NAME = "Service1MockedProfile";
 }

 @Target(ElementType.TYPE)
 @Retention(RetentionPolicy.RUNTIME)
 @Profile(Service2MockedProfile.NAME)
 @interface Service2MockedProfile {

   String NAME = "Service2MockedProfile";
 }
}

@Service
@Profiles.Service1MockedProfile
class MyService {}

@ActiveProfiles(profiles = {Service1MockedProfile.NAME})
class MyServiceTest {}
Thank you Ilya for the suggestion. I took it into account. Do you know if it is possible to have a static final String in a kotlin annotation like we can do in java?