/** * Creates a custom value for VirtualMachineSizeTypes. * @param sku the SKU */ public VirtualMachineScaleSetSkuTypes(Sku sku) { // TODO: This constructor should really be private // Store Sku copy since original user provided sku can be modified // by the user. // this.sku = createCopy(sku); if (this.sku.tier() == null) { this.value = this.sku.name(); } else { this.value = this.sku.name() + '_' + this.sku.tier(); } VALUES_BY_NAME.put(this.value.toLowerCase(), this); }
/** * Creates a custom value for VirtualMachineSizeTypes. * @param sku the SKU */ public VirtualMachineScaleSetSkuTypes(Sku sku) { // TODO: This constructor should really be private // Store Sku copy since original user provided sku can be modified // by the user. // this.sku = createCopy(sku); if (this.sku.tier() == null) { this.value = this.sku.name(); } else { this.value = this.sku.name() + '_' + this.sku.tier(); } VALUES_BY_NAME.put(this.value.toLowerCase(), this); }
/** * Parses a SKU into a VMSS SKU type and creates a new VirtualMachineScaleSetSkuType instance if not found among the existing ones. * * @param sku a VMSS SKU * @return the parsed or created VMSS SKU type */ public static VirtualMachineScaleSetSkuTypes fromSku(Sku sku) { if (sku == null) { return null; } String nameToLookFor = sku.name(); if (sku.tier() != null) { nameToLookFor += '_' + sku.tier(); } VirtualMachineScaleSetSkuTypes result = VALUES_BY_NAME.get(nameToLookFor.toLowerCase()); if (result != null) { return result; } else { return new VirtualMachineScaleSetSkuTypes(sku); } }
/** * Parses a SKU into a VMSS SKU type and creates a new VirtualMachineScaleSetSkuType instance if not found among the existing ones. * * @param sku a VMSS SKU * @return the parsed or created VMSS SKU type */ public static VirtualMachineScaleSetSkuTypes fromSku(Sku sku) { if (sku == null) { return null; } String nameToLookFor = sku.name(); if (sku.tier() != null) { nameToLookFor += '_' + sku.tier(); } VirtualMachineScaleSetSkuTypes result = VALUES_BY_NAME.get(nameToLookFor.toLowerCase()); if (result != null) { return result; } else { return new VirtualMachineScaleSetSkuTypes(sku); } }
@Override public VirtualMachineSizeTypes size() { if (this.inner().hardwareProfile() != null && this.inner().hardwareProfile().vmSize() != null) { return this.inner().hardwareProfile().vmSize(); } if (this.sku() != null && this.sku().name() != null) { return VirtualMachineSizeTypes.fromString(this.sku().name()); } return null; }
@Override public VirtualMachineSizeTypes size() { if (this.inner().hardwareProfile() != null && this.inner().hardwareProfile().vmSize() != null) { return this.inner().hardwareProfile().vmSize(); } if (this.sku() != null && this.sku().name() != null) { return VirtualMachineSizeTypes.fromString(this.sku().name()); } return null; }
/** * Creates a copy of the given sku. * * @param sku the sku to create copy of * @return the copy */ private static Sku createCopy(Sku sku) { return new Sku() .withName(sku.name()) .withTier(sku.tier()) .withCapacity(sku.capacity()); } }
/** * Creates a copy of the given sku. * * @param sku the sku to create copy of * @return the copy */ private static Sku createCopy(Sku sku) { return new Sku() .withName(sku.name()) .withTier(sku.tier()) .withCapacity(sku.capacity()); } }